{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 option is an alias to searchBuilder.preDefined, which should be preferred when using DataTables 2+. It can be used to configure SearchBuilder regardless of how the panes are inserted into the document (layout or searchBuilder).

Please refer to the documentation for searchBuilder.preDefined for full details of this option.

Types

SearchBuilder.Criteria

Description:

Search condition object.

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:

new DataTable('#myTable', {
	layout: {
		top1: 'searchBuilder'
	},
	searchBuilder: {
		preDefined: {
			criteria: [
				{
					condition: '=',
					data: 'Office',
					value: ['Edinburgh']
				}
			],
			logic: 'AND'
		}
	}
});

More Complex Multi level search:

new DataTable('#myTable', {
	layout: {
		top1: 'searchBuilder'
	},
	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:

new DataTable('#myTable', {
	layout: {
		top1: 'searchBuilder'
	},
	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.