在 JQGrid 中动态设置 cellattr 函数不起作用

Set cellattr function dynamically in JQGrid is not Working

我在我的应用程序中使用 jqgrid。我正在为每一列动态准备元数据。 当我为任何列设置 cellattr:"functionname” 时,它不起作用。 因为我在双引号中设置它,所以它不起作用。那么有没有解决这个问题的方法。 我正在从数组加载数据。

请让我知道对此的任何建议。

提前致谢。

如果您使用 jqGrid 4.7.x 或 free jqGrid 4.8.x(这是我的 jqGrid 分支),那么您可以使用字符串作为 [=11= 的值].要在 cellattr(字符串值)的 "name" 之间定义 "mapping",例如 cellattr: "myCellAttr" 和函数实现,您可以使用

$.jgrid.cellattr = $.jgrid.cellattr || {};
$.extend($.jgrid.cellattr, {
    myCellAttr: function (rowId, value, rawObject, cm, rdata) {
        ...
    }
});

参见 my post with the demo and the pull request 合并到 jqGrid 4.7 的代码中。