views:

280

answers:

4

Does anyone has an idea how could I add "myClass" class to some cell (for example, row 5, column 3) in a SlickGrid ?

+1  A: 

..

$('.slick-cell').addClass('myClass'); // adds "myClass" to all cells...

..

$('.slick-row[row=1] .slick-cell[cell=1]').addClass('myClass'); // adds "myClass" to 2nd column of the 2nd row...

note: rows and columns are zero-based index...

Reigel
Great! Thank you!
Misha Moroshko
Do you think this can be done somehow before I call to grid = new Slick.Grid($("#table"), data, columns, options); ?
Misha Moroshko
This will not work since the rows are dynamically created and removed, and the above code will only affect the DOM nodes currently displayed.
Tin
+2  A: 

To add a specific CSS class to some of the rows, use the "rowClasses" option added recently in http://github.com/mleibman/SlickGrid/commit/26d525a136e74e0fd36f6d45f0d53d1ce2df40ed

You cannot add a CSS class to a specific cell, only to all cells in a given column - use the "cssClass" property on the column definition.

Perhaps you can use a combination of those two. Another way is to put an inner DIV inside a cell using a custom formatter and set the class there. Since you have access to row/cell within the formatter, you can decide how to render it.

Tin
Thanks for the idea !
Misha Moroshko
Yes, combining the two works. I used this to set a background color that covered more of the cell than a formatter could provide.
zweiterlinde
A: 

Try something like this:

$(function(){
 $('#element_id tr:eq(4)', '#element_id tr td:eq(2)').addClass('myClass');
});
Sarfraz
A: 

Tin's answer, but it's now called rowCssClasses (and is called with "undefined" a few times in addition to all the regular rows for some reason; I did a

if(row == undefined){ return '' }

just to get through that.

milaniliev