Open malhayek2014 opened 7 years ago
Use changers. http://querybuilder.js.org/#events
// it's a bit unreadable because the first "value" is the value contained by the event (the rule)
// and the second "value" is the actual rule value
$('#builder').on('ruleToJson.queryBuilder.filter', function(e) {
if (Array.isArray(e.value.value)) {
e.value.values = e.value.value;
delete e.value.value;
}
});
Please do not close the issue, I think I will make it the default in version 3
If you need to reuse stored rules :
$('#builder').on('jsonToRule.queryBuilder.filter', function(e, json) {
if (json.values !== undefined) {
e.value.value = json.values;
}
});
This is perfect. Thank you so much.
since you want to add this in v3.0.0, it may not be a bad idea to also parse the string when using "in" and "not_in" and store the parsed string in the values
property
I don't understand, perhaps you want to use the value_separator
filter property.
when when using "in" or "not_in" use the value_separator
to parse the string and store the result in values
and delete value
It'll be one other less step that the user will have to do
Thank you for this awesome package.
I noticed that the
getRules()
function return the user's selected in a property calledvalue
. Value is a string in most time, unlessbetween
or multiple select is used then it is changed to an array.If there a way to override the default behavior so that if the values are array of strings, then put them in a new property called
values
while if the property is a single string it can stay in thevalue
property. This will make parsing the object easier withc#
orASP.NET MVC
framework.Thank you