Extjs gridpanel 单击某个单元格时改变该单元格的背景色

liwu556677 2011-08-18 04:33:46
Extjs gridpanel 单击某个单元格时改变该单元格的背景色,而不是改变整行的背景色,就只要单击那个单元格的背景色。哪位高手可以指点一下呀,好像是grid里面一个属性可以设置的,但是就是找不到那个属性是什么,纠结中,求高手解答呀……
...全文
583 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yh901105 2012-03-09
  • 打赏
  • 举报
回复
单元格的数据错了 我才给背景颜色那
豆虫 2011-08-18
  • 打赏
  • 举报
回复
给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);
});
guoyang842 2011-08-18
  • 打赏
  • 举报
回复
在标题也就是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: id

record :这个单元格对应的record

rowIndex 这是第几行

store 这个表格对应的Ext.data.Store

}
一品 2011-08-18
  • 打赏
  • 举报
回复
添加单元格的单击事件,事件中处理 应该是this.style.backgroundColor 改变就可以的

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧