voidstate
voidstate

Reputation: 7990

How to style a Row in a dGrid

How can I style specific rows of a dGrid?

I have an array of ids for rows which I want to be highlighted but I cannot figure out how to highlight these rows. It's an onDemandGrid with thousands of records so I can't just loop through the rows and do the highlighting.

I've tried applying a renderCell method to a column, then using grid.row( data ) to get the row but I don't think the cell has been attached at the point renderCell is called.

renderCell = function( object, data, cell ) 
{
    // style row
    var row = squadronGrid.row( data );
    console.log( row.element ); // shows as undefined!

What is the correct way to do this?

Upvotes: 0

Views: 2002

Answers (1)

voidstate
voidstate

Reputation: 7990

Got it! Aspect.after to the rescue...

// highlight thumbed rows
aspect.after( myGrid, 'renderRow', function( row, args )
{
    if( rowsToHighlight.indexOf( args[0].id ) != -1 ) // NB. rowsToHighlight is an array of ids
    {
        domClass.add( row, 'dgrid-row-thumbed' );
    }   
    return row;
} );

Upvotes: 6

Related Questions