PDA

View Full Version : How to filter a combo box using regular expression like '?'



raj542
3 Apr 2012, 5:33 AM
Hi all,


i am new to extjs, i am facing difficulty in solving following requirement,


In combobox a drop down list is there.extjs filters the list when we enter any text characters like 'b'... which will display all words starting with 'b'.


Requirement:


while filtering values in combo box, a '?'(question mark) specifies any match from a to z and 0 to 9


Example:i have a list of values like 1.raja 2.123 3.ram 4.1021


1.In the combobox if i enter '?' it should display all values


2.If i enter '?a' it should display raja,ram


3.If i enter '?2?' it should display 123


4.If i enter '?0?1' it should display 1021


Thanks,


Rajasekhar

mitchellsimoens
3 Apr 2012, 12:40 PM
Basically you want to support wildcard. Are you going to have the queryMode stay remote or do it locally? If you do it remote you may need to encode the '?'. If you do it locally then you will need to override the doQuery method as it creates a Filter to filter the store.

raj542
3 Apr 2012, 7:59 PM
Hi,
Thanks for the post.
Can you please provide some sample code how to achieve it using doQuery

Thanks,
Rajasekhar

mitchellsimoens
4 Apr 2012, 4:32 AM
Hi,
Thanks for the post.
Can you please provide some sample code how to achieve it using doQuery

Thanks,
Rajasekhar

What have you tried?

raj542
4 Apr 2012, 4:39 AM
Hi ,
I tried using special key event and keyup events some thing like this,

this.findById('field2').addListener({
keyup : function(f, e){
var l1Store = Ext.StoreMgr.lookup('level2Store');
var re = new RegExp("^[a-z][0-9]+");
l1Store.filter('value',re);
},
specialkey: function(field, e){
if (e.getKey() == e.QUESTION) {
var l1Store = Ext.StoreMgr.lookup('level2Store');
var re = new RegExp("^[1][0-2]+");
l1Store.filter('value',re);
}
}
});
but it didnt work for me...question mark is not recognised.

skotamreddy
21 May 2012, 12:09 PM
Did you find a solution for this? This is exactly what I am looking for.

I overwrote the doQuery, but the regex always returns false.

Thanks,
Srinivas

raj542
28 May 2012, 4:07 AM
Hi Srinivas,
I got solution for this.

Try to use beforequery.

raj

skotamreddy
29 May 2012, 5:41 AM
Thank you Raj. I got it.

- Srinivas