0

I have a jqGrid where JSON data comes from server and I convert it to local data type later. Last column is populated with data, once all other data is loaded from server based on certain conditions. like

 if ((cmgName.substr(-1) === "1") || (cmgName.substr(-1) === "2"))
                $('#list').setCell(rowId, "Compliance", "Yes", {background: '#00FF00'});

While search works fine for other columns, it returns blank for last column for the first time. i.e. if I search for "No", at first it returns blank (0 records). After resetting, if I search for "No". grid returns correct results.

How do I ensure it works correctly for the first time as well. Is it related to creating index over the column or refreshing data?

enter image description here

MalTec
  • 1,350
  • 2
  • 14
  • 33

1 Answers1

0

If you need to set the background color of Compliance column based on the input data then I would recommend you to define cellattr callback in the column. It allows you to set additional class, style, title or any other attributes on the column based on the input data of the cell or based on content of other columns of the row. See the answer, this one or this one as an example. One can combine cellattr with formatters. Thus you can for example display checkboxes (formatter: "checkbox") or "Yes"/"No" textes (formatter: "select") or any other independent from setting the color or background color of the cells of the column.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • it is about deciding the value and not just background color. Issue I see is, no response from search in case of search bar. – MalTec Sep 07 '15 at 19:32
  • @MalTec: You should include **much more information about what you do**. How the column `Compliance` is defined? Which `datatype` you use? Do you use `loadonce: true` or not? Which format have input data you have? Which version of jqGrid you use? – Oleg Sep 07 '15 at 19:47