PDA

View Full Version : dataIndex value on the render event of ExtJS grid



Pravin.Pawar
9 Nov 2012, 2:39 AM
Hi,

I want to get dataIndex value on the render event of ExtJS grid. I have created following function to render values -

function onGridRender(value, meta, record, rowIndex, columnIndex) {
//var c = record.get('change');

}

I have created grid dynamically and NOT sure about the columns names (dataIndex) values so I can't hard coded those values as shown in commented line above.

Render function has value, record, rowIndex and columnIndex somehow columns indexes are not unique as I'm locking some of the grid columns which are disturbing the indexes on lock/ unlock

Please let me know how should I get dataIndex e.g. "change" in render event.

Albareto
9 Nov 2012, 6:50 AM
That looks much more like the renderer function than the render event from the grid panel. Where do you want to get the dataIndex, when the panel is rendered or when the cell values are rendered?

The render event from grid panel receives the panel itself as first argument and extra options as second, have a look to the docs:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.Panel-event-render

Pravin.Pawar
19 Nov 2012, 5:33 AM
I'm invoking this function on column renderer so that i could able to apply different colors to individual cells.

Albareto
19 Nov 2012, 6:23 AM
Last argument for the renderer is the view, so you can get the grid from there and pick the column:


function onGridRender(value, meta, record, rowIndex, columnIndex, view)
{
var dataIndex = view.ownerCt.columns[columnIndex].dataIndex;
}


I don't know if there is a better way.