我已经使用 dojo 实现了一个数据网格,它每 5 秒更新一次。我使用以下代码来更新数据网格。
jsonStore.fetch({
query: {id:'*'},
onComplete: function(items, result){
dojo.forEach(items, function(item){
jsonStore.setValue(item, "time" , data.update[0].netchange);
.....
'data' 是我需要设置到网格的新数据,它是一个 json 对象,如下所示
var data = {"update":[{...}]}
如果 netchage 为负,我需要做什么我需要将单元格颜色设置为红色。如果 netchange 是正数,它应该是绿色的。所以我需要一种动态更改单元格格式的方法。有人可以告诉我如何做到这一点。提前致谢
grid4 = new dojox.grid.DataGrid({
query : {
Title : '*'
},
id : "grid",
jsId : "grid",
clientSort : true,
rowSelector : '0px',
structure : layout4
}, document.createElement('div'));
grid4.setStore(jsonStore);
dojo.byId("gridContainer4").appendChild(grid4.domNode);
var layout4 = [ {
field : 'time',
name : 'time',
width : '40px',
formatter: geticon()
}, {
field : 'netchange',
name : 'netchange',
width : '30px'
} ];