【问题标题】:jqGrid return rowData as stringjqGrid将rowData作为字符串返回
【发布时间】:2014-02-08 09:37:28
【问题描述】:

我有 jqGrid 的本地数据,我为布尔列制作了自定义格式化程序。类似的东西

var boolFormatter = function (cellvalue, opt, rowObj) {
  if (cellvalue == null) return "";
  return (cellvalue == true)
    ? return "Yes"
    : return "No";
}

我喜欢的模特

var colmodel = [
 {index: id, name: id, hidden: true}
 {index: someProperty, name: someProperty, formatter: boolFormatter}
]

问题是当我为对象调用 rowData 时,我得到字符串值,即

var rowData = grid.getRowData(1);
var value = rowData["someProperty"]; 

我知道这是内容值,jqGrid 有它的内部数据存储,我相信所有数据都以正常(真、假、值)格式存储。

请帮忙,我怎样才能将它们作为布尔值。提前致谢!

【问题讨论】:

    标签: jquery-plugins jqgrid jqgrid-formatter


    【解决方案1】:

    在函数boolFormatter 中,当cellvalue == null 时返回值"",当cellvalue == true 时返回值return "Yes" : return "No"。这就是你得到string 值的原因。

    用下面的代码更新你的代码

    var boolFormatter = function (cellvalue, opt, rowObj) {
        if (cellvalue == null) {
           return null;
        } else {
           return (cellvalue == true) ? return true : return false;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 2021-10-23
      • 2012-09-06
      相关资源
      最近更新 更多