View Full Version : How to get handle/reference to grid features, (so can set grid filters)

13 Aug 2012, 12:14 PM
Hi All -

Been looking around the web, but haven't quite found an answer that works.

I am trying to find a way to get a list of grid features, so I can get the filters feature, and set filter checkboxes on a column. The case is that I am loading a grid, then pre-filtering the results down by using the grid filters feature. I can do that directly on the store of course, but then the grid interface is not synchronized to what I've done in the store.

Eventually, I'm trying to do something like:

var gridFilter = grid.getFeature('filter_feature').getFilter("myDataIndexName");

so I can then set the value on the filter as displayed in the grid menu. I've tried various combinations of grid.geatFeature, grid.getView().getFeature() etc, but I can't figure out the right combo from looking at the docs, and the examples I've found around the web don't seem to work for me.

Thanks for any tips...


13 Aug 2012, 12:53 PM
Adding a bit to my original post, the issue is that the getFeature() function seems to be AWOL.

when I say:

grid.getView().getFeature('whatever'), the getFeature method is undefined. However, it seems that it should be in Ext.grid.View and Ext.table.View, from the docs?

Ext version is 4.1.1...



13 Aug 2012, 5:28 PM
Syntax to get a reference to a feature in a grid is <grid>.getView().getFeature(featureId). The following example works well with Ext 4.1.1 and Chrome 20.

Ext.onReady( function() {
var grid = Ext.create('Ext.grid.Panel', {
title: 'Grid Features',
height: 350,
width: 600,
features: [{
id: 'grouping'
renderTo: Ext.getBody(),
columns: {
items: [{
text : 'Company',
flex : 1,
sortable : false,
dataIndex: 'company'


13 Aug 2012, 7:30 PM
vietits -

thanks for the answer. It sounds like I've been trying to do the right thing. I am also using Ext 4.1.1 and Chrome. The grid itself is extended from Ext.grid.Panel

However, when I try to do:


I get a message saying the getFeature() method does not exist. if I check grid.getView.getFeature, it shows as undefined:

TypeError: Object [object Object] has no method 'getFeature'

I'm defining the filters like so:

id: 'filter_feature',
ftype: 'filters',
autoReload: false, //don't reload automatically
local: true, //only filter locally
filters: [] //I am defining these in the individual columns

Any ideas on why the getFilters() method is not appearing as it should? I am using ext-debug.js at the moment...

Thanks for any tips,


13 Aug 2012, 8:29 PM
I found the answer - and I believe it is an ExtJS bug.

when I set:

enableLocking: true,

the getFilters() method would be null. As soon as I remove the locking, everything is hunky dory.

I'll see if I can find where to send bug reports.



13 Aug 2012, 8:50 PM
I see what the trouble you are facing. It's because the grid you created with enableLocking:true is in fact consists of two grids: normal grid and locked grid. In this case, to get a reference to a feature you should use the following syntax:

<grid>.normalGrid.getView().getFeature(featureId) // normal grid
<grid>.lockedGrid.getView().getFeature(featureId) // locked grid
<grid>.getView().lockedView.getFeature(featureId) // locked view
<grid>.getView().normalView.getFeature(featureId) // normal view

16 Nov 2016, 3:12 PM
Did Ext JS added a more neutral api that works with and without locked grid? That seems wrong to have to use different api at such level.