Is there any way to have a selection of null value on multiselect? Or customize the multiselect option using custom array value like the selectbox?
Please explain further what you mean by multiselect. Is it multiselect filter OR select2 multiselect tags?
Also send screenshot of your requirement.
Multiselect here I meant the multiselect filter.
Screenshot : https://imgur.com/KCSzm5t
As you can see at my screenshot.. there is some record have data and some of them is empty/null. But at the filter there’s no option to select the null one. This multiselect filter value is generated by using mysql statement and mysql will ignore the null value. So I’ve been thinking is there any way to customize the multiselect filter, just to make an option to select the null value one.
If your field is numeric id and empty value is 0, then you can simply set:
$col["stype"] = "select-multiple"; $col["searchoptions"]["value"] = "0:-Empty-;".$str;
If your field is string and empty value is “”, then set:
$col["stype"] = "select-multiple"; $col["searchoptions"]["value"] = ":-Empty-;".$str;
If you are looking for null value, it will need some changes in library. Let me know if not resolved.
It is still not resolve on my side.
I’ve checked my database just now and the value is null.
Kindly advice me if you need to change anything from my side.
I found a simple solution for null filtering.
In multiselect-filter settings, add an empty setting:
// multi-select in search filter $col["stype"] = "select-multiple"; $col["searchoptions"]["value"] = ":-Empty-;".$str;
And in column definition, use dbname property and use IFNULL to make it “”.
$col = array(); $col["title"] = "Client"; $col["name"] = "client_id"; $col["dbname"] = "ifnull(invheader.client_id,'')";
So now if you search “” (empty option) it will filter null value.
If using Oracle, use NVL(…) instead of ifnull(…)
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?