本教程知识点是如何改变Grid中某行记录背景颜色,显示结果如图片:
示例代码:http://www.itdatum.net/webui/extjs/2014/08/7930.html
在线演示:http://www.itdatum.net/online/extjs/examples-itdatum/grid-summary-2/grid-summary-2.html
实现方式是为Grid配置viewConfig属性,自定义实现getRowClass函数。
核心代码如下:
Ext.define('Itdatum.view.UserList' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.userlist',
title : 'All Users',
store: 'UserStore', /* getRowClass:更改行样式 */ viewConfig:{getRowClass:changeRowClass}, initComponent: function() {
this.columns = [
{header: 'Name', dataIndex: 'name', width:100},
{header: 'Idno', dataIndex: 'idno', width:150},
{header: 'Gender', dataIndex: 'type', width:60,renderer : function(v) {return v==1 ? '男' : '女';}},
{header: 'Birthday', dataIndex: 'birthday', width:120},
{header: 'Email', dataIndex: 'email', flex: 1}
];
this.callParent(arguments);
}
});
function changeRowClass(record, rowIndex, rowParams, store){
if (record.get("type") == "1") {
return 'x-grid-record-yellow';
}
}
tr.x-grid-record-yellow .x-grid-td {
background: YELLOW;
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11984612/viewspace-1254959/ ,如需转载,请注明出处,否则将追究法律责任。