I want to retrieve the value of a cell from a grid while clicking any cell from that row.
I am not using the checkbox selection model in my grid. I don't find any solution for the grid where checkbox model isn't used.
I am trying to retrieve the value using the following ways but I am receiving 'undefined'.
listeners: {'cellclick': {fn: function(grid, cellIndex, rowIndex, columnIndex, value, e) {
alert("grid "+grid+" rowIndex "+rowIndex+" columnIndex "+columnIndex+" e "+e+" cellIndex "+cellIndex);
alert("record "+cellIndex.data);
record = grid.getStore().getAt(rowIndex);
cellvalue = record.get(colname);
}//funtion
In the above code, cellIndex.data
is undefined. Also I tried, cellIndex.value
and various other possibilities.
For example, what I want is, when I click the 5th column of a row, I want to retrieve the cell value on 1st column of the same row. How to achieve this?
It doesn't look like your listener method signature is correct. For Ext JS 4.2, the handler for the cellclick event takes the following arguments:
this, td, cellIndex, record, tr, rowIndex, e, eOpts
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.Panel-event-cellclick
Once you have the correct signature, you'll notice that the cellclick event also passes the record
which is the model instance bound to the row on which the cellclick event occurred. You should be able to use this to easily retrieve the value from any field within your model instance without having to separately lookup the record from the store first...you already have it.
Also, be sure to pay attention to the data types for the arguments. cellIndex
, for example, is a Number, not an object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.