dojox DataGrid onStyleRow works first time, then not again

后端 未结 2 2009
一生所求
一生所求 2020-12-22 01:31

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://dojot

2条回答
  •  旧时难觅i
    2020-12-22 02:36

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

提交回复
热议问题