我是 ext-js 的新手。
我有一个容器网格,我需要做的是:如果一行中 2 列之间的差异大于 2,则该行应为红色。
我不知道该怎么做。
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'val_1',
text: 'val_1'
},
{
xtype: 'gridcolumn',
dataIndex: 'val_2',
text: 'val_2'
}
最佳答案
试试这个例子
Ext.onReady(函数(){
var store = Ext.create('Ext.data.ArrayStore', {
字段:['价格', '变化'],
数据:[
[0, 0],
[2, 3],
[0, 1],
[2, 3],
[5, 6],
[0,0]
]
});
var grid = Ext.create('Ext.grid.Panel', {
title: '阵列网格',
商店:商店,
列:[
{text: 'Price', width: 75, dataIndex: 'price'},
{text: 'Change', width: 75, dataIndex: 'change'}
],
View 配置:{
stripeRows: false,
getRowClass: function(record) {
return record.get('price')+record.get('change') > 2 ? 'change-row-color':'';
}
},
高度:200,
宽度:200,
渲染到:Ext.getBody()
});
});
CSS:
.change-row-color .x-grid-cell {
背景颜色:#ffe2e2;
颜色:#900;
关于javascript - 在 ExtJS 中使用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17992537/