PDA

View Full Version : Grid Filter params not being sent to server



hallikpapa
6 Apr 2014, 12:58 PM
I have a basic grid, and I have added some filters to columns. I added them in the constructor like so, since some of them use stores. All the search menus show up properly, and when I type in a box, or select an option from a list menu, the load event is fired from the store.


constructor: function(config) {
Ext.apply(this, {
features : [{
ftype: 'filters',
encode: true,
local: false,
filters: [{
type: 'string',
dataIndex: 'name'
},{
type: 'string',
dataIndex: 'priority'
},{
type: 'list',
store: Ext.getStore('adminCategory'),
dataIndex: 'adminOrg',
labelField: 'displayName'
},{
type: 'list',
store: Ext.getStore('adminClientList'),
dataIndex: 'client',
labelField: 'name',
listeners: {
activate: function(obj, eOpts) {
console.log(obj);
}
}
}]
}]
});
this.callParent(arguments);

Again, the menu items load just fine, however when the filter activates, and starts to load the store, the filter params are not present, so they aren't submitted to the server. Where it's a ListFilter or the basic TextFilter.

I checked the beforeload event on the store, and the filters array is empty (in the operations object where all the sorter info is stored too).

Why wouldn't the values be sent and a filter array be created to send to the server, when the actual "filtering" event seems to work just fine. Using extjs v4.2.1

hallikpapa
7 Apr 2014, 11:20 AM
After some digging, I noticed that the FiltersFeature onBeforeLoad event is being called three times.

The first time, it has all my filters present. However, the 2nd and 3rd time it's called, the params are empty. I will also note, the beforeload event on my store is called only once, Then FiltersFeature onBeforeLoad is called 3 times.

This is because I have the same grid 3 times in a tab panel (3 tabs).

Is there a way I can make the the FiltersFeature fire onBeforeLoad for only the active tab? Each grid is it's own instance, so I am not sure why the FiltersFeature is getting called for each one. However, each grid uses the same store instance. So I am guessing the filter beforeload event is being added to the store 3 times, and it doesn't have a way of knowing which grid fired the rule. Looking for a way to prevent this.



Ext.define('App.view.projectmgmt.task.TabPanel', {
extend: 'Ext.tab.Panel',
alias: 'widget.projectmgmt-tasktabpanel',
mixins: ['App.ux.Event'],
requires: [
'App.view.projectmgmt.task.List'
],
layout: 'fit',
activeTab: 0,
tabPosition: 'top',
items: [{
title: 'Active',
xtype : 'projectmgmt-tasklist'
},{
title: 'Done',
xtype : 'projectmgmt-tasklist'
},{
title: 'Archived',
xtype : 'projectmgmt-tasklist'
}]
});

hallikpapa
7 Apr 2014, 5:54 PM
My problem was I had defined a storeId. Once I created a new store for each instance of my grid, it worked fine.

Gary Schlosberg
8 Apr 2014, 4:58 AM
Glad to hear you've gotten it resolved and thanks for sharing your findings with the community.