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 when the value of the editoptions are set. For example editoptions: { value:"Yes: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.
So how do I implement the offval attribute for my checkbox formatter? Thanks in advance!
I don’t think that you need to set any
offvalattribute inside of your custom checkbox formatter. jqGrid set the attribute itself if one usesedittype: "checkbox"(see the part of code). So it seems to me that you don’t need to setoffvalneither 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
offvaland I just includedoffval="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
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 offormatter: "checkbox"in the column definition of the corresponding column. I find this way very practical.