Reputation: 409
Is it possible to style the selected row of a Datagrid programmatically?
Can anyone give a snippet ?
Upvotes: 2
Views: 3925
Reputation: 971
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);
});
Upvotes: 0
Reputation: 8641
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 {
}
Upvotes: 1
Reputation: 1978
Why not simply overriding the right css class? Otherwise you might want to look at onStyleRow and styleRowState function
Upvotes: 0