2

我正在编写一个自定义复选框格式化程序,但我无法理解该offval属性的用途以及它的值应该是什么。

尤其是在设置了 editoptions 的值时。例如editoptions: { value:"Yes:No" }

我可以看到默认的复选框格式化程序总是offvalno. 这个api 文档说它也可以设置为off. 在代码中,我还看到该值可以设置为 editoptions 的第二个值。在示例的情况下,No但这可以是任何提供的值。

那么如何为我的复选框格式化程序实现 offval 属性呢?提前致谢!

4

1 回答 1

0

我认为您不需要offval在自定义复选框格式化程序中设置任何属性。如果使用,jqGrid 会自行设置属性edittype: "checkbox"(参见代码部分)。因此,在我看来,如果您也创建了自定义格式化程序,也不需要在自定义编辑控件中进行设置offval

顺便说一句,在我发布格式化程序代码的时候:“clickableCheckbox”我和你有同样的问题。我不明白的意思,offval我只是包含offval="no"在代码中。:-)。我认为这没有任何意义,但要确保必须测试所有原因。

如果您编写多次使用的自定义格式化程序,我建议您使用

(function ($) {
    "use strict";
    $.extend($.fn.fmatter, {
        yourFormatterName: function (cellValue, options) {
            ....
        }
    });
    $.extend($.fn.fmatter.yourFormatterName, {
        unformat: function (cellValue, options, elem) {
            ...
        }
    });
}(jQuery));

as prototype of the formatter. In the way you will register new formatter "yourFormatterName" which you can use exactly like any other predefined formatters: you need just use formatter: "yourFormatterName" instead of formatter: "checkbox" in the column definition of the corresponding column. I find this way very practical.

于 2013-01-31T12:23:22.980 回答