问题描述
如何根据严重性条件更改数据网格中的行颜色?我是这个 EXTJS 主题的新手.我曾经使用reader来读取,store到store和writer来写数据.将所有数据提取到网格中后,如何根据严重性条件更改数据网格中的行颜色?你能解释一下代码工作吗?
How can I change the row colour in datagrid based upon the severity condition? I'm new to this EXTJS topic. I used to reader to read, store to store and writer to write the data. After fetching all the data into the grid, how can i change the row colour in datagrid based upon the severity condition? Can you explain me too bit with code working?
推荐答案
您可以使用 GridView 类 (Ext.grid.GridView) 来操作网格.您还可以使用 GridPanel 的 viewConfig 属性.下面是一个例子:
you can use the GridView class (Ext.grid.GridView) to manipulate the user interface of the grid. You can also the viewConfig property of the GridPanel. Here is an example:
viewConfig: {
//Return CSS class to apply to rows depending upon data values
getRowClass: function(record, index) {
var c = record.get('change');
if (c < 0) {
return 'price-fall';
} else if (c > 0) {
return 'price-rise';
}
}
}
ps:示例取自 ExtJS API 文档本身
ps: Example taken from ExtJS API documentations itself
价格下跌和价格上涨是具有相应设置背景颜色的 CSS.例如:
The price-fall and price-rise are CSS that have background colors set accordingly. eg:
.price-fall {
background-color: #color;
}
.price-rise {
background-color: #color;
}
这篇关于如何根据严重性更改数据网格中的行颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!