开发者

jqgrid row background colour change

开发者 https://www.devze.com 2022-12-21 00:24 出处:网络
I have a jq grid, and I have to check for a particular value in a column and change t开发者_JAVA百科he row corresponding to the column (say red).

I have a jq grid, and I have to check for a particular value in a column and change t开发者_JAVA百科he 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


Try this:

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


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消