{hero}

searchBuilder.preDefined

Since: SearchBuilder 1.0.0

Set a predefined search query.
Please note - this property requires the SearchBuilder extension for DataTables.

Description

This is useful as it allows for complex preDefined searches to be applied to a DataTable.

This object contains 2 properties.

  • searchBuilder.preDefined.criteria This holds the criteria that must be applied to the top group. This property is an array of objects, which can either be criteria objects, group objects or a mix of the two. This is where the bulk of the configuration for preDefined searches takes place.
  • searchBuilder.preDefined.logic This is the logic operator that will be applied to the group.

For more information on how all of the configuration options for preDefined searches are brought together, please refer to the manual page for preDefined searches.

Types

object

Description:

The details object for the top level group.

boolean

Description:

When false no predefined search is applied.

Default

  • Value: false

The default value for the searchBuilder.preDefined option is false meaning that as standard there will be no preDefined search applied.

Examples

Simple single level search:

$('#example').DataTable( {
	dom: 'Qlfrtip',
	searchBuilder: {
		preDefined: {
			criteria:[
				{
					condition: '=',
					data: 'Office',
					value: ['Edinburgh']
				}
			],
			logic: 'AND',
		}
	}
});

More Complex Multi level search:

$('#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 suitable 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.