PDA

View Full Version : Add grid filter programmatically



Nxs
6 Sep 2012, 12:32 AM
Hi,

I have a grid that is already rendered, and I try to add to it a filter (Ext.ux.grid.FiltersFeature) dynamically.

This is the way I follow:



// Create filter property
var filtersCfg = {
ftype: 'filters',
autoReload: true,
encode: true,
local: false,
filters: [{
type: 'numeric',

dataIndex: 'Stock'

}]
}

// Apply config on the fly
Ext.apply(grid, { features: filtersCfg });


That's not seem to change anything on the grid (the filter menu on the stock column is still not visible).

Although in Chrome console the 'features' property on the grid is filled with the filter config and has the stock filter in the 'filters' array...:s

Do I need to refresh something ? Or what is the right way to simply add a new column filter on the fly ?

Thanks.

tvanzoelen
6 Sep 2012, 1:34 AM
Have you loaded/included the ux library (js) separately? Its not default in the Ext library.

Nxs
6 Sep 2012, 2:16 AM
Yes I already use it with other grids created by prog (not by a designer) so I can set directly the grid's features property in the "Ext.create..." function and filters work perfectly.