禁用属性自定义复选框格式化程序jqGrid [英] Offval attribute custom checkbox formatter jqGrid

查看:96
本文介绍了禁用属性自定义复选框格式化程序jqGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个自定义复选框格式器,无法理解offval属性的用途以及该属性的值.

I am writing a custom checkbox formatter and I have trouble understanding where the offval attribute is used for and what it value should be.

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

Especially when the value of the editoptions are set. For example editoptions: { value:"Yes:No" }

我可以看到默认的复选框格式化程序始终将offval设置为no.此 api文档说,也可以将其设置为off .在代码中,我还看到该值可以设置为editoptions的第二个值.对于No的示例,但这可以是任何提供的值.

I can see that the default checkbox formatter always sets the offval to no. This api documentation says it can also be set to off. In the code I also see that the value can be set to the second value of the editoptions. In case of the example to No but this can be any provided value.

那么,如何为复选框格式化程序实现offval属性?预先感谢!

So how do I implement the offval attribute for my checkbox formatter? Thanks in advance!

推荐答案

我认为您无需在自定义复选框格式化程序内设置任何offval属性.如果使用edittype: "checkbox",jqGrid会自行设置属性(请参见offval %3acustom_formatter"rel =" nofollow>自定义格式化程序

I don't think that you need to set any offval attribute inside of your custom checkbox formatter. jqGrid set the attribute itself if one uses edittype: "checkbox" (see the part of code). So it seems to me that you don't need to set offval neither in your custom formatter nor in custom editing control if you create it too.

顺便说一下,当我发布格式化程序:"clickableCheckbox" 我和您有相同的问题.我不理解offval的含义,我只在代码中包含了offval="no". :-).我认为这没有任何意义,但请确保必须测试所有原因.

By the way in the time when I posted the code of formatter: "clickableCheckbox" I had the same question as you. I didn't understood the mean of offval and I just included offval="no" in the code. :-). I don't think that it has any sense, but to be sure one have to test all of cause.

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

If you write your custom formatter which you use multiple times I would recommend you to use

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

作为格式化程序的原型.以这种方式,您将注册新的格式化程序"yourFormatterName",您可以像使用其他任何预定义的格式化程序:您只需要在相应列的列定义中使用formatter: "yourFormatterName"而不是formatter: "checkbox".我觉得这种方式非常实用.

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.

这篇关于禁用属性自定义复选框格式化程序jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆