{hero}

searchBuilder.conditions

Since: SearchBuilder 1.0.0

Define custom conditions for SearchBuilder.
Please note - this property requires the SearchBuilder extension for DataTables.

Description

This option allows custom conditions to be added to SearchBuilder, to extend or replace the standard ones.

This object contains the following properties, whose value is a further object of the type searchBuilder.conditions[type]. More details for the types can be found at columns.type.

  • string - Column type for strings. This is also the default should none of the below types match the data in the column.
  • date - Date / time values. Note that DataTables' built in date parsing uses Javascript's Date.parse() method which supports only a very limited subset of dates. Additional date format support can be added through the use of plug-ins.
  • num - Simple numbers with no formatting
  • num-fmt- Numbers with formatting such as currency.
  • html - Basic strings that also make use of html tags
  • html-num - Basic numbers that also make use of html tags.
  • html-num-fmt - Numbers with formatting that also make use of html tags
  • moment Formatted dates. This is used in combination with the DataTables Ultimate Sorting Plug-in.
  • luxon Formatted dates. This is used in combination with the DataTables Ultimate Sorting Plug-in for luxon
  • array The array type is used in combination with columns.orthogonal data and provides better conditions for columns that use arrays. This is not automatically identified, the columns.type must be set to array for these to be used.
  • It is also possible to add your own custom types. Using the columns.type initialisation option and adding a property of the same type name in this object. You can define your own conditions for custom types either through a plug in, or initialisation.

The standard conditions can be removed, edited or added to. The manual page for custom conditions covers this in detail.

More details on the structure that is used can be found at searchBuilder.conditions[type]. More details on the built in types can be found at columns.type

Note: When using a custom decimal place character, the SearchBuilder internals will replace this with a . so that the correct processing can take place. It is worth bearing this in mind when customising the functions that each condition runs.

Note: Please also not that custom conditions are not supported when the serverSide option is set to true.

Examples

There are two examples that create custom conditions using initialisation options. They both show how to add a custom condition to the num column type, but the process is the same for other column types.

There is also an example that shows how to use a plug-in to add a custom condition.

Type

Object

Description:

An object that contains conditions for each of the built in DataTables types as defined in columns.type along with moment and luxon types for formatted dates, an array type for columns with an array format and any other custom types that may exist on the table.

Default

  • Value: Object

The default value for the searchBuilder.conditions option is an object with a property for each of the built in DataTables types as defined in columns.type along with moment and luxon types for formatted dates, an array type for columns with an array format and any other custom types that may exist on the table. Each property in turn is an object with key value pairs to represent the conditions. These objects have the structure of searchBuilder.conditions[type][cond].

Related

The following options are directly related and may also be useful in your application development.