dojox DataGrid onStyleRow第一次工作,然后不再工作

我正在尝试使用DataGrid制作一个图例.我的问题是,我希望Datagrid中的文本是彩色的.我使用了这里概述的onStyleRow函数:(http://dojotoolkit.org/reference-guide/dojox/grid/DataGrid.html),它在部署后第一次工作. DataGrid中的文本显示为红色,但如果我刷新或打开在不同的浏览器上尝试,则DataGrid文本不会显示为红色,只是标准黑色.

我在想,我做错了什么,谢谢,
这是我的代码:

if(dijit.byId("plotlegend")){
    dijit.byId("plotlegend").destroy();
}

var threadGrid = new dojox.grid.DataGrid({
    id: 'plotlegend',store: oStore,structure: layout,rowsPerPage: 5,rowSelector: false,autoWidth: true,query: {},plotsObject: this.plotsObject,onStyleRow: function(row){
        var legend = this;
        var item = legend.getItem(row.index);
        if (item){
                var variableName = legend.store.getValue(item,"plot");
            if (variableName){
                var color = "color:red;";
                row.customStyles += color;
            }
        }

        legend.focus.styleRow(row);
        legend.edit.styleRow(row);
    }
},document.createElement('div'));

dojo.byId("plotlegendbc").appendChild(threadGrid.domNode);
threadGrid.startup();
threadGrid.update();
不确定这是否会解决您的问题,但如果您的自定义样式函数的最后一行是:
dojox.grid.DataGrid.prototype.onStyleRow.apply(this,arguments);

(删除grid.focus.styleRow和grid.focus.edit.styleRow行)此代码将更加向前兼容,因为它直接运行默认的onStyleRow函数.

相关文章

我有一个网格,可以根据更大的树结构编辑小块数据.为了更容易...
我即将开始开发一款教育性的视频游戏.我已经决定以一种我可以...
我正在使用带有Grails2.3.9的Dojo1.9.DojoNumberTextBox小部...
1.引言鉴于个人需求的转变,本系列将记录自学arcgisapiforja...
我正在阅读使用dojo’sdeclare进行类创建的语法.描述令人困惑...
我的团队由更多的java人员和JavaScript经验丰富组成.我知道这...