dojox DataGrid onStyleRow works first time, then not again

自古美人都是妖i 提交于 2019-11-29 16:36:53

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.

I have had more success in using dojo.connect to handle this event and properly apply styles. I haven't used the individual styles as CSS classes are a better way to manage styles. It is better for maintenance because then you don't have individual styles embedded in your JavaScript. Here's a snippet of what works for me. Keep in mind this is on Dojo 1.5.

var grid = dijit.byId('myDataGrid');
dojo.connect(grid, 'onStyleRow' , this, function(row) {                    
    var item = grid.getItem(row.index);
    if (item) {
        if(item.status != "viewed"){
            row.customClasses += " unRead";
        }else{
            row.customClasses += " read";
        }

        if(item.status == "not active"){
            row.customClasses += " dismissed";
        }
    }
    grid.focus.styleRow(row);
    grid.edit.styleRow(row);
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!