开发者

Extjs store filtering - include metachars

I have a data store having a Note field (a textarea) and want to display all Notes satisfying a user input (even metacharacters).

I've written the following function to handle this:

function notefilter() {
    var newfilter = Ext.getCmp('searchnote');
    var searchStr = newfilter.getValue();
    searchStr = searchStr.replace('?', '\\?').replace('*', '\\*').replace('+', '\\+').replace('{', '\\{').replace('}', '\\}').replace('[', '\\[').replace(']', '\\]').replace('(', '\\(').replace(')', '\\)').replace('|', '\\|').replace('$', '\\$').replace('^', '\\^');

    var re = new RegExp(".*" + searchStr + ".*开发者_开发知识库", "ig");
    Ext.getCmp('notesgrid').store.filter('Note', re);
}

However the filter fails to search for metacharacters even after escaping them, but it works are all other alphanumeric input.

Am I missing something ?

Thanks in advance !


Finally, got the filter working. JavaScript's built in escape() & encodeURIComponent() did the work for me. I do not have to programatically escape the metachars.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜