Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find column index using dataIndex Extjs 4

Well in ExtJS 3 i used the following code:

grid.getColumnModel().findColumnIndex("Tasks")

I tried finding it on the api docs, but no luck...so how is ir possible that i can find the column index of the grid by the dataIndex of the column or the header name of that column.

like image 358
Hmxa Mughal Avatar asked Dec 06 '12 11:12

Hmxa Mughal


2 Answers

The most standard way to get a column by dataIndex would be:

var column = grid.columnManager.getHeaderByDataIndex('Tasks')

Note that this does return a column (contrary to the function name). This is because a grid header in ExtJS is actually both a header and a column contents.

Ext.grid.column.Column docs:

This class specifies the definition for a column inside a Ext.grid.Grid. It encompasses both the grid header configuration as well as displaying data within the grid itself.

See also: getHeaderByDataIndex docs.

like image 82
Nux Avatar answered Sep 24 '22 17:09

Nux


You can use the component query:

var fname = grid.down('[dataIndex=firstname]');

It took a while to work that out - there doesnt seem to be an example in the docs. ;-)

like image 26
Murrah Avatar answered Sep 21 '22 17:09

Murrah