我正在尝试使用DataGrid制作一个图例.我的问题是,我希望Datagrid中的文本是彩色的.我使用了这里概述的onStyleRow函数:(http://dojotoolkit.org/reference-guide/dojox/grid/DataGrid.html),它在部署后第一次
我在想,我做错了什么,谢谢,
这是我的代码:
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函数.
