我正在尝试使用 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();