View Full Version : HELP: Combobox filtering

5 Oct 2007, 10:09 AM
I'm filtering the store of the combo box yet the combobox still displays all the records.
any ideas?

abreviated code.....
ds = new store({....});
cb = new combobox({...,store=ds,...});
ds.filterBy(function(r) {
if (r.data[id]=='1') return true;
return false;

I have also rearranged the code so that the filter occurs before the combo is created.
I see the combo's store filtered in firebug yet the combo still displays all records.
Does it have to do with the store's snapshot?

5 Oct 2007, 3:50 PM
What other options are you passing/not passing to the combo?

6 Nov 2007, 3:45 AM
I have same problem!
First time I set filter all records display other times
filter correct display record!

How can resolve?

6 Nov 2007, 4:34 AM
Try putting filtering code into load event of store.

29 Nov 2007, 10:13 PM

We are having the same problem. I have placed the filtering code in the load event of the store, the record is successfully removed from the store, but it still displays it in the combo.

combo.store.on('load', function()
alert('unfiltered count: ' + combo.store.getCount()); // Returns 25

var include = record.get('Id') != '680';
return include;

alert('filtered count: ' + combo.getCount()); // Returns 24

If anyone above has solved the problem, can you please post the resolution?

30 Nov 2007, 8:34 AM
Try using ext-all-debug and set some BPs. Filtering the store should fire datachanged, which should then execute DataView.refresh(), which should update the display. Can you see this happening?

2 Dec 2007, 8:03 PM
I can see the datachanged and DataView.refresh() being fired but the item still isn't removed.

When I click on the item in the list that should've been filtered, I am able to retrieve its details from the record supplied to the 'select' event!

2 Dec 2007, 8:16 PM
Update: When I place an alert at the end of the load event callback, after I set focus to the combo, the item is removed. If I place the alert anywhere before the call to set focus, the record stays in the data store

11 Sep 2008, 10:51 PM
Hi All,
Please let me know if I have posted in the wrong area.
Guess this is one of the solutions.
Here is what I did to get my ComboBox to show up with filtered elements.
It worked for me. Please have a look. Let me know if it works for you.
Change it based on your needs.

var dsTemplate = new Ext.data.Store({ /*Config*/});

var templateCombo = new Ext.form.ComboBox({....store: dsTemplate,...});

//handling on 'load' event
templateCombo.store.on('load', function(){

alert('===In=== '+templateCombo.store.getCount());


if((record.get('id')== '4' || record.get('id')== '5' || record.get('id')== '9' ) && pageTracker == "HR")
return record.get('name');
else if((record.get('id')== '6' || record.get('id')== '7' || record.get('id')== '8' ) && pageTracker != "HR")
return record.get('name');
alert('==Out==' + templateCombo.getCount());

10 Oct 2008, 4:59 AM
Not sure if this is what you're after.

This code will purge records from the store on load/reload of the store:

this.store.on('load', function(){
var recordsToRemoveArr = [];
this.filterBy(function(record, id){
if (record.get('someField') === someValue) {
return true;

for( var i = 0, len = recordsToRemoveArr.length; i < len ; i ++ ){
this.remove( recordsToRemoveArr[i] );
}, this.store);