如何在编辑单元格后更改dojo DataGrid行的字体颜色

时间:2011-07-29 22:24:17

标签: dojo dojox.grid.datagrid

我想在编辑该行中的单元格并将其设置为某个值后更改行的字体颜色。 myStore是与dojox.grid.DataGrid dataGrid关联的dojo.data.ItemFileWriteStore。

我写了这个:

myStore.onSet = function(item, attribute, oldValue, newValue) { 
    if (item.myField == myValue) {
        var index = dataGrid.selection.selectedIndex;
        dojo.style(dataGrid.getRowNode(index), "color" , "red");
    }
}

但不幸的是,这没有任何影响...

更新:我添加了以下样式属性:“backgroundColor”:“red”。好吧,行的背景颜色变为红色,但当鼠标离开行时,颜色会变回默认值!可能是某些默认事件处理程序恢复了默认样式...

1 个答案:

答案 0 :(得分:0)

dojo.style行可以自行调用它。您的函数根本没有被调用,if的条件为false或者没有选择行,并且您获得的索引编号无效。 (你可以在那里放一些console.logs来检查)