how to set the cell background color baced on the cell value in jqgrid?
Asked Answered
A

2

2

I'm using jqgrid. I need to set background color of the cell based on the values.

I have tried using the following code after reload the table the color is disabled.

jQuery("#list").setCell ('5','5','t',{background:'#ff0000'});

I want to set the cell background color on table loading, based on the cell values. how to do this?

Thanks in advance.

Almandine answered 12/3, 2011 at 6:53 Comment(0)
T
8

You can do this in many ways: see this, this or this. Important is not only how you do this, but where. The loadComplete event handle is the good place for that.

UPDATED: In the next version of jqGrid you will able to use new cellattr option as function in the colModel. See this demo and my original suggestion.

Trexler answered 12/3, 2011 at 8:0 Comment(0)
O
1

To use the cellattr functionality with the asp.net library of jqGrid, add this to your column. I can't find this documented well anywhere else online...

<Formatter>
    <trirand:CustomFormatter SetAttributesFunction="clientSideFunctionName" />
</Formatter>

And Thank Oleg for the awesome addition to jqGrid :)

Oskar answered 11/2, 2014 at 23:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.