PDA

View Full Version : Flexible dataIndex in grid columns



allistar
30 Apr 2013, 2:25 AM
Hi all,
I have a grid which has the ability of displaying 3 different types of rows, "A", "B" and "C". The grid has a single Ext.dataModel defined in the usual way.

Each record in the store identifies which of the 3 row types it is. I need to be able to decide the dataIndex for a column based on the row type. E.g.

For the second column if the row type is "A" then the dataIndex to use is "fieldA", if it's a "B" row then the data index to use is "fieldB". So the dataIndex for the column is dependent on some other field in the record that is being displayed.

How would I achieve this? I am comfortable extending existing ExtJS classes, so doing that is not a problem.

Thanks,
Allistar.

evant
30 Apr 2013, 2:36 AM
Currently there's no way to set the dataIndex of a column dynamically. If you're just looking to set the display value you can use a renderer.

allistar
30 Apr 2013, 2:51 AM
Thanks. Looks like I may have to either reimplement Ext.grid.header.Container::prepareData, or alternatively create a new Ext.grid.feature.Feature to provide this functionality.