John Smith
John Smith

Reputation: 2108

how to get dataIndex by column index in ExtJS 6/7

This works in old versions:

var dataIndex = grid.getHeaderCt().getHeaderAtIndex(columnIndex).dataIndex; 

I need the exact functionality for ExtJS 7.

I noticed that in newer versions you can get the header with grid.getHeader(), but I can't find any method from Ext.panel.Header that could give me the dataIndex.

Thanks.

Upvotes: 0

Views: 861

Answers (1)

wahab memon
wahab memon

Reputation: 2416

There are many different ways to get the dataIndex from grid using indexes. Below are some of them:

grid.getHeaderContainer().getHeaderAtIndex(index).dataIndex;

grid.getColumnManager().getHeaderAtIndex(index).dataIndex;

grid.getColumns()[index].dataIndex;

You should not look in Ext.panel.Header as it contains configs related to the grids header containing the title. Instead look in Ext.grid.header.Container which will have configs related to grid column headers. Refer the documentation link: https://docs.sencha.com/extjs/6.5.3/classic/Ext.grid.header.Container.html

Upvotes: 2

Related Questions