【发布时间】:2014-03-16 14:21:15
【问题描述】:
我有一个加载数据列表的网格,其中一些数据应该通过特定日期值更改背景值。如果日期小于今天的日期,则应使用'now'的css类,否则使用'later'。 它确实工作正常,但我的问题是只有一行正在改变背景颜色,所以它不会遍历整个列表。
这是我的网格:
grid = Ext.create('Ext.grid.Panel', {
store: store,
xtype: 'gridpanel',
columns: [
{ text: 'Name', dataIndex: 'name', tdCls: 'x-grid-cell' }
],
stripeRows: false,
viewConfig: {
getRowClass: function(record, index) {
var date = Ext.Date.parse(record.get('reminderDate'),"c").valueOf();
var today = Ext.Date.parse(Ext.Date.format(new Date(), 'Y-m-d'), "c").valueOf();
return today < date ? 'later' : 'now'
}
},
renderTo: Ext.getBody()
});
编辑:
背景颜色仅在网格的顶行发生变化,其余保持不变。但是,getrow 类会调用每一行。
CSS:
.later .x-grid-cell {
background-color: #FFB0C4;
}
.now .x-grid-cell {
background-color: #5491BD;
}
【问题讨论】:
-
你是说
getRowClass没有为每一行调用,或者每一行的背景颜色没有改变? -
每一行都调用它。每行的背景颜色都不会改变
-
那可能是你的css有问题。
-
我添加了css文件。