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 theselect
element.searchBuilder.preDefined.criteria.condition
The condition that is to be selected from theselect
element.searchBuilder.preDefined.criteria.value
The condition that is to be applied, be it to either aselect
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.
When using predefined searches with server-side processing there are two additional properties that must be set:
searchBuilder.preDefined.criteria.origData
The original field name that the server-side script should filter on.searchBuilder.preDefined.criteria.type
The type of conditions that should be used when filtering this data.
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'
}
}
});
Simple single level search for SSP:
$('#example').DataTable( {
dom: 'Qlfrtip',
searchBuilder: {
preDefined: {
criteria:[
{
condition: '=',
data: 'Office',,
origData: 'office',
type: 'string',
value: ['Edinburgh']
}
],
logic: 'AND',
}
}
});
Related
The following options are directly related and may also be useful in your application development.