searchBuilder.preDefined.criteria
Declares criteria and sub-groups within the array.
Please note - this property requires the SearchBuilder extension for DataTables.
Description
This property is used to define sub-groups and criteria within the searchBuilder.preDefined
option.
It is possible within this option to define a mix of both sub-groups and criteria. This is because a single group can hold multiple sub-groups and/or criteria at the same time
To add a sub-group an object should be added that is in the same form as searchBuilder.preDefined
. This in turn can hold its own criteria and sub-groups nested to any depth you desire.
To add a criteria an object with the following properties should be defined:
searchBuilder.preDefined.criteria.data
The data that is to be selected from the select element.searchBuilder.preDefined.criteria.condition
The condition that is to be selected from the select element.searchBuilder.preDefined.criteria.value
The condition that is to be applied, be it to either a select element, input or date selector.
When it comes to applying the selected data
, condition
and value
values to a condition, SearchBuilder will work through them in that order and stop as soon as one is not defined. For example if you defined data
and value
but not condition
then the data selection would be made, but the value would not as the condition can not be determined.
For more information on preDefined searches please refer to the searchBuilder.preDefined
option or the manual page.
Type
Default
- Value:
[]
The default value for the searchBuilder.preDefined.criteria
option is []
meaning that as standard there are no criteria or sub-groups defined.
Examples
Simple single level search with only criteria:
$('#example').DataTable( {
dom: 'Qlfrtip',
searchBuilder: {
preDefined: {
criteria:[
{
condition: '=',
data: 'Office',
value: ['Edinburgh']
}
],
logic: 'AND',
}
}
});
More Complex Multi level search with sub-groups and criteria on the same level:
$('#example').DataTable( {
dom: 'Qlfrtip',
searchBuilder: {
preDefined: {
criteria:[
{
condition: '=',
data: 'Office',
value: ['Edinburgh']
},
{
criteria: [
{
condition: '=',
data: 'Name',
value: ['Cedric Kelly']
},
{
condition: '=',
data: 'Name',
value: ['Dai Rios']
}
],
logic: 'OR'
}
],
logic: 'AND'
}
}
});
Related
The following options are directly related and may also be useful in your application development.