In extjs, for the record object, is there a awy to get a particular data index. What I need is this: I have a renderer function that formats decimals. If the dataIndex of the record is a 'dollaramount', i format one way. If something else, I format another way. So the function is:
decimalsRenderer: function(value, metaData, record, rowIndex, colIndex, store){
if (record.data.index =='amount')
// 开发者_开发知识库 format using 2 decimals
else
//format using 3 decimals
},
But record.data.index is not allowed. How can i do it?
I think you are confusing column and record.
Record does not have dataIndex but Column has one.
dataIndex for the column tells the grid "for this column, we want to look at this particular field from the store"
That said, here is how you can obtain the dataIndex i.e. the field name (from store's point of view) in your column renderer -
//columnIndex is availble in renderer fn
var fieldName = grid.getColumnModel().getDataIndex(columnIndex);
//Do your thing. check if fieldName is amount
Reference - ColumnModel
精彩评论