加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 22:03:24 所属栏目:百科 来源:网络整理
导读:我正在尝试使用DataGrid制作一个图例.我的问题是,我希望Datagrid中的文本是彩色的.我使用了这里概述的onStyleRow函数:(http://dojotoolkit.org/reference-guide/dojox/grid/DataGrid.html),它在部署后第一次工作. DataGrid中的文本显示为红色,但如果我刷新
我正在尝试使用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函数.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读