3

I want to set the JQGRID row bgcolor depends upon the condition? How to do it? Im using php.

Thanks in advance,

jerry
  • 185
  • 2
  • 4
  • 10

1 Answers1

6

look at jqGrid Coloring an entire line in Grid based upon a cells value. You should examine current row values after data loading (inside of loadComplete for example). For the elements where you want change the background-color you should remove 'ui-widget-content' css class and then add another class which defines the color which you want.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • afterInsertRow: function(rowid, aData, rowelem) { if (aData.field =='value'){ jQuery("#list1").setCell(rowid,'name','',{color:'red'}); } } The above code change the column text color. want to change the row background color.... {background-color:'red'} is not working. – jerry Aug 23 '10 at 06:49
  • 2
    Sorry, but do you read my answer http://stackoverflow.com/questions/2931732/jqgrid-coloring-an-entire-line-in-grid-based-upon-a-cells-value/2936673#2936673? To change background color for a row you should **remove 'ui-widget-content' CSS class** for the row before, because 'ui-widget-content' define background image and because of that a simple changing of color how you wrote can not work. Moreover I recommend always use `gridview: true` and make changing of the grid inside of `loadComplete` and NOT inside of `afterInsertRow` is you not want to have less performance. – Oleg Aug 23 '10 at 07:40
  • Its working..Thanks u so very much Oleg.. before i misunderstood your answer..sorry. – jerry Aug 23 '10 at 07:44
  • Not a problem. You welcome! Only one general recommendation about the usage of the stackoverflow. You asked already 3 questions in stackoverflow. Please look at http://stackoverflow.com/faq#howtoask and conside to mark the answers which really solve your problem as accepted and to vote other helpful answers. This will help other users easy to find the best or the most helpful information on the stackoverflow. – Oleg Aug 23 '10 at 09:25