Sorting Jqgrid如何在数据类型为本地(或loadonce:true)时保留cellattr条件格式?

Sorting Jqgrid如何在数据类型为本地(或loadonce:true)时保留cellattr条件格式?,sorting,jqgrid,filtering,local,Sorting,Jqgrid,Filtering,Local,我有一个jqgrid,使用loadonce:true选项加载大量行(1000秒)。加载jqgrid后,用户将在本地对数据进行操作。我还对其中一列进行了条件格式化,如下所示 cellattr: function(rowId, cellValue, rawObject, cm, rdata) { if (rawObject[0]=='Stale'){ return ' class="stale-highlight"'; } else if (rawObject[0]==

我有一个jqgrid,使用loadonce:true选项加载大量行(1000秒)。加载jqgrid后,用户将在本地对数据进行操作。我还对其中一列进行了条件格式化,如下所示

 cellattr: function(rowId, cellValue, rawObject, cm, rdata) {
     if (rawObject[0]=='Stale'){
    return ' class="stale-highlight"';
     } else if (rawObject[0]=='Not Stale') {
    return ' class="notstale-highlight"';
     } 
 }
它可以正常工作,但条件是一旦用户这样做,所有格式都将丢失 分类、过滤等

我知道这可能与loadonce选项有关,该选项在加载网格后将数据类型更改为local。如何允许用户在不轮询servrr的情况下对数据进行操作,但仍保留条件格式化

谢谢 卡斯比

**

更新: **

我发现了问题。希望它能对其他人有用

为了减小数据大小,我使用以下json格式:

{"rows":[{"id":"1","cell":["Not Stale","xxxx","2012-10-16 14:20:59",
                           "110517853","10797445","2012-10-17 08:29:51",
                           "xxxx","2012-10-17 08:33:02", "xxxx",
                           "105954724","xxxxxx","11111.0000",
                           "10000000.0000","10000000.0000"]}]
 ,"page":1,"total":1,"records":"2"} 
三是在json中没有列名称。因此,最初加载网格时,cellattr中使用的rawObject参数是一个值数组(对应于列)。加载栅格后,rawObject成为一个对象。它包含两对列\u name:column\u value

因此,我的原始代码只能在初始电网负荷期间工作

cellattr: function(rowId, cellValue, rawObject, cm, rdata) {
     if (rawObject[0]=='Stale'){
      return ' class="stale-highlight"';
      } else if (rawObject[0]=='Not Stale') {
       return ' class="notstale-highlight"';
   } 
}
要解决此问题,我可以看到两个选项:

use the column_name:column_value pairs in the json object and change the cellattr code to reference the rawObject.column_name.

谢谢Casbby

add extra logic to check rawObject.column_name in the cellattr function. it may be less efficient programmingwise but sometime changing input is not that easy

    cellattr: function(rowId, cellValue, rawObject, cm, rdata) 
    { if   (rawObject[0]=='Stale' || rawObject.column_name=='Stale')
       { return ' class="stale-highlight"'; } 
     else if (rawObject[0]=='Not Stale' || rawObject.column_name=='Not Stale') 
       { return ' class="notstale-highlight"'; }