Extjs gridpanel 单击某个单元格时改变该单元格的背景色,而不是改变整行的背景色,就只要单击那个单元格的背景色。哪位高手可以指点一下呀,好像是grid里面一个属性可以设置的,但是就是找不到那个属性是什么,纠结中,求高手解答呀……

解决方案 »

  1.   

    添加单元格的单击事件,事件中处理 应该是this.style.backgroundColor 改变就可以的
      

  2.   

    在标题也就是column 或者columnModel  、
    加个属性
    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} 
      

  3.   

    给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);
    });