给grid添加cellclick事件 grid.on('cellclick',function cellclick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); //Get the Record var fieldName = grid.getColumnModel().getDataIndex(columnIndex); //Get field name var data = record.get(fieldName); alert('当前选中的数据是'+data); });
加个属性
renderer:function(value){
if(value<3){ //楼主可以根据自己想要的条件设置 或者不要
return "<table><tr><td onclick="this.style.backgroundColor"></td></table>" }
}
下面是renderer的参数
renderer:function (value, cellmeta, record, rowIndex, columnIndex, store) { value :这个单元格的值;cellmeta.cellId: 这个单元格的配置cellmeta.id: idrecord :这个单元格对应的record rowIndex 这是第几行store 这个表格对应的Ext.data.Store}
grid.on('cellclick',function cellclick(grid, rowIndex, columnIndex, e) {
var record = grid.getStore().getAt(rowIndex); //Get the Record
var fieldName = grid.getColumnModel().getDataIndex(columnIndex); //Get field name
var data = record.get(fieldName);
alert('当前选中的数据是'+data);
});