Question

Is it possible to style the selected row of a Datagrid programmatically?

Can anyone give a snippet ?

Was it helpful?

Solution

Try this (here's a fiddle with modified reference guide example):

var grid = new dojox.grid.DataGrid({
    id: 'grid',
    store: store,
    structure: layout,
    rowSelector: '20px',
    onClick: function() {
        // ( selection.selected is array for multiple)
        var index = this.selection.selectedIndex,
        // typically 1 here, mess with it if nogo on solution
        viewindex = 1,
        RAWROWNODE = this.views.views[viewindex].rowNodes[index]

    }
}, document.createElement('div'));

You can also look into the stylesheet, used by grid component.

.dojoxGridRow,
.dojoxGridRowOdd,
.dojoxGridRowSelected {
}

OTHER TIPS

Why not simply overriding the right css class? Otherwise you might want to look at onStyleRow and styleRowState function

Try this

 dojo.connect(grid, 'onStyleRow', this, function (row) {
    if (grid.selection.selectedIndex == row.index) {
       row.customStyles += "color: red;";            
    }

    grid.focus.styleRow(row);
    grid.edit.styleRow(row);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top