1

I have a jqgrid and I would set a background color for a row.

 ....,
 gridComplete: function(){
        var ids = jQuery("#tabImprese").jqGrid('getDataIDs');
        for(var i=0;i < ids.length;i++){
            var cl = ids[i];
        ...........
        }

    },....

How can I do? Thanks.

michele
  • 26,348
  • 30
  • 111
  • 168
  • which criteria you use to find which rows you want to highlight with another background color? Depend on the criteria I could suggest you another way for the highlighting. – Oleg Aug 05 '11 at 13:34
  • if the content row has a specific value I would highlight it. – michele Aug 05 '11 at 14:28
  • in particular if a column has a value == at another column – michele Aug 05 '11 at 14:44

3 Answers3

0

you can use $yourRow.effect("highlight", {color:"whateverColoryourwant"},3000);

Evan
  • 5,975
  • 8
  • 34
  • 63
0

You can access the row using the following selector:

jQuery("#" + cl, "#tabImprese").

I have used this to apply an effect to a row, for example a temporary highlight:

jQuery("#" + rowId).effect("highlight", {}, 2000);

But you also should be able to add a class to the row to apply your own custom highlighting.

Community
  • 1
  • 1
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
0

I understand your question so, that you want to change the background color of some rows based on the content of the column of the row.

You can do this in many ways. You need enumerate all rows inside of loadComplete or gridComplete event handler add the class to the row element (<tr>) or set background CSS style. The most important thing is just how you enumerate all rows and examine the content of the row. The answer shows the most effective method (this.rows[iRow]cells[iCol]) to enumerate the rows and examine the column contain. Another answer discuss advantages and disadvantages of different ways how the background color could be changed.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798