{hero}

searchBuilder.preDefined.criteria

Since: SearchBuilder 1.0.0

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:

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:

For more information on preDefined searches please refer to the searchBuilder.preDefined option or the manual page.

Type

object[]

Description:

An array of objects which represent either a sub-group or a criteria.

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.