{hero}

searchBuilder.conditions[type][cond].search

Since: SearchBuilder 1.0.0

Define the comparison function for the condition.
Please note - this property requires the SearchBuilder extension for DataTables.

Description

This function is what the condition uses to filter the table. It takes three parameters.

  • value the value that is present in the DataTable.
  • comparison an array of values, with each index representing the number of value input that the value is to be filtered against.
  • that the criteria instance, should any of it's internal properties be required.

This function is to return a boolean, true if the row is to be included in the result, false if not. Both the value from the table and the value(s) that were collected in the searchBuilder.conditions[type][cond].inputValue. This function is free to perform any operation on those values to decide whether it passes the desired condition. This function then is the crux of the searching behaviour for the condition.

The manual page for custom conditions covers in detail how this and the other values in this object come together to create a custom condition.

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.

Type

function searchBuilder.conditions[type][cond].search

Description:

The function that is used when filtering the DataTable.

Parameters:
Returns:

Returns a boolean indicating whether it has passed the criteria or not

Examples

Include the row if it equals the selected value:

...    
search: function(value, comparison, that) {
    return +value === +comparison[0];
}
...

Include the row if it is a multiple of the selected value:

...    
search: function(value, comparison, that) {
    return +value % +comparison[0] === 0;
}
...

Related

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