You found a bug! We've classified it as
EXTJS-26928
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Sencha User
Filters ignore stateful filters flag on store
The filters plugin appears to be ignoring the state flag on the store due to hard coded true in the filters init. This is making it not possible to have a stateful grid the excludes the statefulness on store filters. The if (grid.stateful) { store.statefulFilters = true; } appears to trample user specified config.
ExtJs Version 6.2.167
located in 'Ext.grid.filters.Filters'
Code:
init: function(grid) {
var me = this,
store, headerCt;
Ext.Assert.falsey(me.grid);
me.grid = grid;
grid.filters = me;
if (me.grid.normalGrid) {
me.isLocked = true;
}
grid.clearFilters = me.clearFilters.bind(me);
store = grid.store;
headerCt = grid.headerCt;
me.headerCtListeners = headerCt.on({
destroyable: true,
scope: me,
add: me.onAdd,
menucreate: me.onMenuCreate
});
me.gridListeners = grid.on({
destroyable: true,
scope: me,
reconfigure: me.onReconfigure
});
me.bindStore(store);
if (grid.stateful) {
store.statefulFilters = true;
}
me.initColumns();
}
-
Sencha User
Possible override
Code:
Ext.override(Ext.grid.filters.Filters, {
init: function (grid) {
var me = this,
store, headerCt;
Ext.Assert.falsey(me.grid);
me.grid = grid;
grid.filters = me;
if (me.grid.normalGrid) {
me.isLocked = true;
}
grid.clearFilters = me.clearFilters.bind(me);
store = grid.store;
headerCt = grid.headerCt;
me.headerCtListeners = headerCt.on({
destroyable: true,
scope: me,
add: me.onAdd,
menucreate: me.onMenuCreate
});
me.gridListeners = grid.on({
destroyable: true,
scope: me,
reconfigure: me.onReconfigure
});
me.bindStore(store);
me.initColumns();
}
});
Sample Store Config Parameters
Code:
store: {
autoDestroy: true,
statefulFilters: false,
saveStatefulFilters: false,
model: primaryStore.model,
groupers: [],
data: [],
proxy: {
type: 'memory'
}
},
-
Thanks for the report and override. Can you please post a test case which reproduces the problem?
https://fiddle.sencha.com/#view/editor
-
Sencha User
I created a fiddle to illustrate that the disabling stateful filters on grids is being ignored.
https://fiddle.sencha.com/#view/editor&fiddle/1s1o
-
Sencha Premium Member
+1 we're having this same issue.
The behaviour is plain wrong, the config just gets blindly overwritten which renders it redundant.
This issue is still in a state of info required; what additional information is still required on this ticket?
-
Sencha User
+1, this bug is still an issue for us.
-
Sencha User
I have reviewed the test case initially provided to work smoothly on ExtJS 6.5.0. Seems Ext.encodeValue() does not work well if some of the object's keys are null, so I just removed it.
Here's the reviewed fiddle: Filter State Not Disabling.
Initially, it will not work. The override and variant are commented out in the beginning of app.js. To reproduce the issue then:
1. click the last column ("Visible") dropdown menu.
2. click the 'filters' menu entry, so that it filters the column for all the 'false' values. the column title will be bold, underlined and italics.
3. click the 'Get Grid State' button (third button in grid's top bar)
The output will display a storeState > filters key.
Uncomment either one of the blocks in app.js (first block is lines 5-35, second block would be 39-50). They both do basically the same, just one fully overrides and the other relies on callParent().
Then as you repeat steps 1,2,3 above change also the line 57 either commenting, setting to false (so it uses default value), and setting to true. Depending on line 57:
- If commented: the default will be the original: if the grid is stateful, then the filters are also stateful (docs says stateful is false by default, but makes sense making true whenever the grid is true, so that's in purpose). So when you click the "Get Grid State" button in step 3 above, the "filters" key will be there.
- If set to false: the specified value will prevail. Clicking "Get Grid State" on step 3 will not include the "filters" key onthe result.
- If set to true: the specified value will prevail. Clicking "Get Grid State" on step 3 will include the "filters" key, as if the line was commented out.
I hope this helps reproducing the issue and applying the fix to the current ExtJS version.