【问题标题】:How to change font color of a dojo DataGrid row after a cell has been edited如何在编辑单元格后更改 dojo DataGrid 行的字体颜色
【发布时间】:2011-07-29 22:24:17
【问题描述】:

我想在该行中的一个单元格被编辑并设置为某个值后更改该行的字体颜色。 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”。好吧,行的背景颜色变成了红色,但是当鼠标离开行时,颜色又变回了默认值!可能是某些默认事件处理程序恢复了默认样式...

【问题讨论】:

    标签: dojo dojox.grid.datagrid


    【解决方案1】:

    如果您自己调用 dojo.style 行,它就可以工作。要么您的函数根本没有被调用,if 的条件为假,要么没有选择任何行,并且您得到的索引编号无效。 (你可以放一些console.logs在那里查看)

    【讨论】:

    • mmm...索引已正确记录,还有 RowNode 对象。但可能 dojo.style 不应该以这种方式工作。你还会尝试什么?
    猜你喜欢
    • 2011-11-10
    • 2016-06-16
    • 2015-08-31
    • 2012-08-02
    • 2014-06-16
    • 2022-08-23
    • 2012-12-05
    • 1970-01-01
    • 2021-04-06
    相关资源
    最近更新 更多