Is there any chance to use CheckBox as jqGrid Filter? Assuming, that i have field with values only 0 and 1. If checkbox will be checked then filtred value will be 1, no filtering.
-
2How you want to display the third state: no filtering by the column? Because of the requirement to have 3-state input one use typically `stype: "select", searchoptions: { sopt: ["eq", "ne"], value: ":Any;1:Yes;0:No" }` in the column. It creates the select with three displayed values: `"Any"`, `"Yes"` and `"No"` (or some other texts which you prefer). – Oleg Feb 08 '16 at 15:55
-
You're right. Then i would like no filtering when unchecked. – Lukaszaq Feb 09 '16 at 07:12
1 Answers
The reason, why one don't use checkboxes in the filter toolbar, is very simple: one need 3-state checkbox: checked, unchecked and not-defined:
- "checked" state means filtering by checked (1 value in your case)
- "unchecked" state means filtering by unchecked (0 value in your case)
- "not-defined" state means no filtering by the column
Because of that one use mostly the property like
stype: "select", searchoptions: { sopt: ["eq", "ne"], value: ":Any;1:Yes;0:No" }
to have drop-down select element in the filter toolbar. The texts "Any", "Yes" and "No", like the values 1 and 0 can be changed to another values depend on your requirements.
UPDATED: jqGrid allows to to create custom searching interface by usage stype: "custom"
and implementing custom_element
and custom_value
callbacks of of searchoptions
See the old answer and the Searching Dialog. I would still don't recommend you to do this, because it makes things more complex without any real benefit for the user. I'm sure that some users will ask you for filtering about non-checked state: the more users the more different opinions. Select is the standard interface which know everybody and everybody understand it's meaning in the same way.
I modified the old demo to the following which demonstrates the possibility of stype: "custom"
in the searching toolbar. After the click on the custom control of the filter toolbar one will see the picture like below:
I used in the demo of cause free jqGrid fork of jqGrid - the fork, which I develop staring with the end of 2014.
-
-
1@Lukaszaq: jqGrid allows to to create custom searching interface by usage `stype: "custom"` and implementing `custom_element` and `custom_value` callbacks of of `searchoptions` See http://stackoverflow.com/a/12744780/315935 and Searching Dialog. I would still don't recommend you to do this, because it makes things more complex without any real benefit for the user. I'm sure that some users will ask you for filtering about non-checked state: the more users the more different opinions. Select is the *standard* interface which know everybody and everybody understand it's meaning in the same way. – Oleg Feb 09 '16 at 12:47
-
@Lukaszaq: I updated an old demo to demonstrate the usage of `stype: "custom"`: see [the modified demo](http://www.ok-soft-gmbh.com/jqGrid/OK/Ranking_free_jqgrid.htm). – Oleg Feb 09 '16 at 13:51