dojox DataGrid onStyleRow第一次工作,然后再也不行 [英] dojox DataGrid onStyleRow works first time, then not again

查看:88
本文介绍了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函数,因此该代码将更加前向兼容。


I am trying to make a legend using a DataGrid . My problem is, I want the text in the Datagrid to be colored. I use the onStyleRow function as outlined here: (http://dojotoolkit.org/reference-guide/dojox/grid/DataGrid.html) and it works the first time after deploying. The text in the DataGrid comes up red, but if i refresh or open try it on a different browser, the DataGrid text does not come up red, just the standard black.

I was wondering, what I was doing wrong, Thanks, Here is my code:

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();

解决方案

Not sure if this will solve your issue, but it's better if the last line of your custom style function is: dojox.grid.DataGrid.prototype.onStyleRow.apply(this, arguments);

(Remove the grid.focus.styleRow and grid.focus.edit.styleRow lines) This code will be more forward compatible since it runs the default onStyleRow function directly.

这篇关于dojox DataGrid onStyleRow第一次工作,然后再也不行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆