PDA

View Full Version : Event fired on Grid Filter



aminef
13 Dec 2010, 8:35 AM
I just want to know what event is fired by a Filter on grid so I can catch it with the grid (I tried Events.Change and it doesn't seem to work)

Thank you

sven
13 Dec 2010, 8:37 AM
What do you want to do exactly? You want to know when the store updated its filtering?

aminef
13 Dec 2010, 8:39 AM
Well I want to catch the value set on the filter everytime it changes so I can highlight it basically, everything is ready but the catch of the value, and I even tried Events.Update and Events.Change.

Here's my code:

GridFilters filters = new GridFilters();
final RenderDataFilter contactFilter = new RenderDataFilter("Contact");

final RenderDataFilter otherFilter = new RenderDataFilter("Other");
filters.addFilter(contactFilter);
filters.addFilter(otherFilter);
filters.setLocal(true);
grid.addPlugin(filters);

grid.addListener(Events.Update, new Listener<GridEvent<PersInfo>>() {
@Override
public void handleEvent(GridEvent<PersInfo> be) {
Info.display("Change", "Filter");
if(contactFilter.getValue() != null) setFilterField("Contact", contactFilter.getValue().toString());
if(otherFilter.getValue() != null) setFilterField("Other", otherFilter.getValue().toString());
}
});

sven
13 Dec 2010, 8:48 AM
The Grid is not related to this and so does not fire any events at all.

You can listen to the Events.Update, Events.Activate and Events.Deactivate events on the filters directly for example

aminef
13 Dec 2010, 8:49 AM
Oh!
I am so stupid, i wasn't thinking...
Thank you

lizucagirl
28 Nov 2011, 3:02 AM
Hi,

I want to be able to change the filter's value (because I want to filter based on time duration) and I'm listening to the 'filterupdate' grid's event. This event is trigerred in onStateChange function in GridFilters.js.
What I'm experiencing is that store's filter param is NOT updated.
this.grid.on(
{
'filterupdate':
{
fn: function(GridFilter,filterParam)
{
var filters2= [];

var jsonFilters = this.grid.filters.getFilterData();
Ext.each(jsonFilters, function(f)
{
var index = this.grid.getColumnModel().getIndexById(f.field);
if(f.field == 'TalkTime') {
//var func = this.getColumnModel().getRenderer(index);
f.data.value = sdLib.sec2oa(f.data.value);

}
filters2.push(f);

}, this);

Ext.apply(this.store.baseParams,
{
filter: Ext.encode(filters2)
});

this.store.reload();
},
scope: this

}

});
When I inspect my request, the filter param is still in the format filter[{"type":"numeric","comparison":"lt","value":50,"field":"TalkTime"}]
instead of [{"field":"TalkTime","data":{"type":"numeric","comparison":"lt","value":0.0005787037037037037}}]

I noticed the fact that filters are constructed in getSerialArgs function in NumericFilters.js.
How can I get this thing sorted?

Many thanks for any idea!