john doe
john doe

Reputation: 816

Set background color of cell in a column based on a particular condition in jqgrid

I want to change background colors(say,red) of all cells in a column(say, Total Sale) where column value is more than x(say, 10)? How can this be achieved.

Upvotes: 0

Views: 2834

Answers (1)

Ibrahim Khan
Ibrahim Khan

Reputation: 20740

You can use formatter for total column.

{
    name: "total",
    index: "total",
    formatter: function(cellvalue, options, rowObject){
        if(cellvalue>10)
            return '<span style="background-color: red; display: block; width: 100%; height: 100%; ">' + cellvalue + '</span>';
        else
            return cellvalue;
    }
}

DEMO

Upvotes: 1

Related Questions