Offval attribute custom checkbox formatter jqGrid

后端 未结 1 1156
予麋鹿
予麋鹿 2021-01-22 07:41

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.

Especially wh

相关标签:
1条回答
  • 2021-01-22 08:14

    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.

    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));
    

    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.

    0 讨论(0)
提交回复
热议问题