PDA

View Full Version : How to Grid Filiter?



TrojanMyth
13 Dec 2010, 1:40 AM
Hi;

I want to filter grid from combobox.

myComboBox.addListener(Events.Change, new Listener<FieldEvent>() {

@Override
public void handleEvent(FieldEvent be) {
mygrid.getStore().filter("field","beginWith");
// i dont want to begin with. i want to filter equals.
}
});

How can i?

sven
13 Dec 2010, 3:02 AM
Use a real filter and skip the second argument on the filter method.

TrojanMyth
13 Dec 2010, 4:53 AM
How to use StoreFilter ? Can you send sample code?

harun
13 Dec 2010, 5:10 AM
override the store isFiltered( ModelData record, String property ) method like below:


GroupingStore<ModelData> store = new GroupingStore<ModelData>() {
@Override
protected boolean isFiltered( ModelData record, String property)
{

if ( filterBeginsWith != null && property != null ) {
Object o = record.get( property );
if ( o != null ) {
if ( !o.toString().toLowerCase().equals( filterBeginsWith.toLowerCase() ) ) {
return true;
}
}
}
if ( filters != null ) {
for ( StoreFilter filter : filters ) {
boolean result = filter.select( this, record, record, property );
if ( !result ) {
return true;
}
}
}
return false;

};
};



it is working for me...

sven
13 Dec 2010, 5:22 AM
And not really needed, because you could use a StoreFilter for this.