Search code examples
extjsextjs3

beforequery with filter is not working in IE6 extjs


I am facing an issue with IE6 while using filter with beforequery function in extjs 3.4, here is my code.

this.findById('field1').addListener({
        beforequery: function(e) {
            var metadataStep = Ext.getCmp('step2');
            if (e.query && e.query.indexOf('?') != -1) {
                var temp = '';
                for(var i=0;i<e.query.length;i++){
                    temp = temp + '['+e.query[i]+ ']';
                }
                e.cancel = true;
                var query = new RegExp(String.format('^{0}',temp.replace(/\?/g, 'a-zA-Z0-9\-\.,:\+\*\(\)=\'&_')));
                if (combo.store.getCount() > 0 || combo.listEmptyText) {
                    combo.expand();
                    combo.restrictHeight();
                }
                this.store.clearFilter(true);
                this.store.filter(this.displayField, query);
            }
        }
    });

Note: Its working in ff and Chrome

1.I am getting query as/^[undefined]/ in IE6.

2.But in Chrome and FF query = /^[a-zA-Z0-9-.,:+*()='&_]/

Any help is highly appreciated.

Thanks in advance,

Raj


Solution

  • if (e.query && e.query.indexOf('?') != -1) {
        e.query = String.format('^{0}', e.query.replace(/\+/g, '[\+]'));
        e.query = String.format('^{0}', e.query.replace(/\(/g, '[\\(]'));
        e.query = String.format('^{0}', e.query.replace(/\)/g, '[\\)]'));
        e.query = String.format('^{0}', e.query.replace(/\*/g, '[\*]'));
        e.query = String.format('^{0}', e.query.replace(/\./g, '[.]'));
        e.cancel = true;
        var query = new RegExp(String.format('^{0}',e.query.replace(/\?/g, '[a-zA-Z0-9\-\.,:\+\*\(\)=\'&_]')));
        if (combo.store.getCount() > 0 || combo.listEmptyText) {
            combo.expand();
            combo.restrictHeight();
        }
        combo.store.clearFilter(true);
        combo.store.filter(combo.displayField, query);
       }
    

    this code is working fine.In IE6 array is not working.