views:

671

answers:

2

Hi All

I have a jq grid, and I have to check for a particular value in a column and change the row corresponding to the column (say red).

I can get the row index, but I can't work out how to access that row and change its background.

TIA Bibhu

A: 

As far as i know there isn't a way to change the cell color from the server-side. However, you can inject onReady javascript into the browser to change the cell colors once done rendering. Here is an example of the javascript:

$(document).ready(function() {
    $('#myGrid tr:nth-child(1) td:nth-child(2)').addClass("highlight");
});

This will change the class of the cell at position 2 (1-based) in row 1 of your grid (Id "myGrid") to "highlight". If you need the code for injecting javascript from the server-side here is a C# example:

this.Page.ClientScript.RegisterStartupScript(
    typeof (myPage), 
    "scriptIdentifier", 
    "The JavaScript you want to send to the page", 
    true);
Pete Amundson
A: 

Try this:

afterInsertRow: function(rowid, aData, rowelem)
     { 
        if (aData.field =='value'){   
            jQuery("#list1").setCell(rowid,'message','',{color:'red'});  
        }  
     } 
marc bertaud