我在ExtJS 5中给某些单元添加样式时遇到麻烦。在索引页中有两个样式规则:
.yellow-cell .x-grid-cell{
font-weight: bold;
background-color: yellow;
}
.red-cell .x-grid-cell{
color:blue;
background-color: red;
}
在select
事件中,所选择的小区应该是彩色的yellow-cell
规则。以及需要使用其他规则着色的单元格red-cell
,该表的其余部分仅是默认值。
var gridTable = Ext.getCmp('gridTable');
gridTable.on("select",function(obj, record, index, eOpts){
gridTable.getView().addItemCls(record, 'yellow-cell');
});
并取消选择,removeItemCls()
然后使用addItemCls()
来添加red-cell
样式。
有没有适当的方法可以做到这一点?因为我的代码仅对整行进行着色,而我仅对所选/取消选择的单元格进行着色。
我真的被困在这里,任何帮助将不胜感激。
gridTable.getView()。getCell(rec,col).addCls('yellow-cell');
您也可以尝试console.log(record)找到正确的div名称,然后执行以下操作:
Ext.get('idOfcellDiv ...')。addClas('yellow-cell');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句