SearchBuilder Criteria only uses the first item in array, skips everything else
SearchBuilder Criteria only uses the first item in array, skips everything else

Link to test case: N/A
Debugger code (debug.datatables.net): N/A
Error messages shown: No errors
Description of problem: SearchBuilder preDefined
criteria
(client side) only displays the first item of the array instead of multiple values
searchBuilder: {
columns: [0, 1, 2, 3, 4, 5, 6],
preDefined: {
criteria: [
{
data: 'Amount',
condition: '>=',
value: [500]
},
{
data: 'Names',
condition: '!contains',
value: ['Rotten Apples', 'Frozen Banana', 'Rusty Pineapple']
},
],
logic: 'AND'
}
}
I have tried ['Apple', 'Banana', 'Pineapple']
and ["Apple", "Banana", "Pineapple"]
using Jinja2 built-in tojson filter but DataTables is only showing the first item in array.
Question: Does contains
and !contains
only accept one value in array? Is it recommended to use a group with multiple conditions or create a custom condition for this scenario? I am looking to use the built-in conditions as best as I can.
Answers
Correct. The end user input for
contains
and!contains
is a string. There is no way for them to enter an array of values. The array forvalue
is used for things likebetween
where two values are needed.If you need multiple conditions such as this, then yes, you'd need to break it down into multiple conditions in the criteria array.
You could create a custom condition which makes use of a
multiple
select
field, or perhaps use something like Select2, but I suspect that would be more work!Allan