Class: Filters

Filters

This plugin allows filtering the table data either by the built-in component or with the API.

handsontable-pro/src/plugins/filters/filters.js, line 30

Members

componentsMap

Map, where key is component identifier and value represent BaseComponent element or it derivatives.

conditionCollectionConditionCollection

Instance of ConditionCollection.

conditionUpdateObserverConditionUpdateObserver

Instance of DropdownMenu.

eventManagerEventManager

Instance of EventManager.

hiddenRowsCacheMap

Hidden menu rows indexed by physical column index

lastSelectedColumnObject

Object containing information about last selected column physical and visual index for added filter conditions.

Default Value:
  • null

trimRowsPluginTrimRows

Instance of TrimRows.

Methods

handsontable-pro/src/plugins/filters/filters.js, line 261

addCondition(column, name, args, operationId)

Add condition to the conditions collection at specified column index.

Possible predefined conditions:

  • begins_with - Begins with
  • between - Between
  • by_value - By value
  • contains - Contains
  • empty - Empty
  • ends_with - Ends with
  • eq - Equal
  • gt - Greater than
  • gte - Greater than or equal
  • lt - Less than
  • lte - Less than or equal
  • none - None (no filter)
  • not_between - Not between
  • not_contains - Not contains
  • not_empty - Not empty
  • neq - Not equal

Possible operations on collection of conditions:

  • conjunction - Conjunction on conditions collection (by default), i.e. for such operation: c1 AND c2 AND c3 AND c4 ... AND cn === TRUE, where c1 ... cn are conditions.
  • disjunction - Disjunction on conditions collection, i.e. for such operation: c1 OR c2 OR c3 OR c4 ... OR cn === TRUE, where c1, c2, c3, c4 ... cn are conditions.
  • disjunctionWithExtraCondition - Disjunction on first n - 1* conditions from collection with an extra requirement computed from the last condition, i.e. for such operation: c1 OR c2 OR c3 OR c4 ... OR cn-1 AND cn === TRUE, where c1, c2, c3, c4 ... cn are conditions.

* when n is collection size; it's used i.e. for one operation introduced from UI (when choosing from filter's drop-down menu two conditions with OR operator between them, mixed with choosing values from the multiple choice select)

Note: Mind that you cannot mix different types of operations (for instance, if you use conjunction, use it consequently for a particular column).

Parameters:
Name Type Description
column Number

Visual column index.

name String

Condition short name.

args Array

Condition arguments.

operationId String

id of operation which is performed on the column

Example
// Add filter "Greater than" 95 to column at index 1
hot.getPlugin('filters').addCondition(1, 'gt', [95]);
hot.getPlugin('filters').filter();

// Add filter "By value" to column at index 1
// In this case all value's that don't match will be filtered.
hot.getPlugin('filters').addCondition(1, 'by_value', [['ing', 'ed', 'as', 'on']]);
hot.getPlugin('filters').filter();

// Add filter "Begins with" with value "de" AND "Not contains" with value "ing"
hot.getPlugin('filters').addCondition(1, 'begins_with', ['de'], 'conjunction');
hot.getPlugin('filters').addCondition(1, 'not_contains', ['ing'], 'conjunction');
hot.getPlugin('filters').filter();

// Add filter "Begins with" with value "de" OR "Not contains" with value "ing"
hot.getPlugin('filters').addCondition(1, 'begins_with', ['de'], 'disjunction');
hot.getPlugin('filters').addCondition(1, 'not_contains', ['ing'], 'disjunction');
hot.getPlugin('filters').filter();
handsontable-pro/src/plugins/filters/filters.js, line 352

clearColumnSelection()

Clear column selection.

handsontable-pro/src/plugins/filters/filters.js, line 284

clearConditions(column)

Clear all conditions previously added to the collection for the specified column index or, if the column index
was not passed, clear the conditions for all columns.

Parameters:
Name Type Description
column Number optional

Visual column index.

handsontable-pro/src/plugins/filters/filters.js, line 640

destroy()

Destroy plugin.

handsontable-pro/src/plugins/filters/filters.js, line 188

disablePlugin()

Disable plugin for this Handsontable instance.

handsontable-pro/src/plugins/filters/filters.js, line 105

enablePlugin()

Enable plugin for this Handsontable instance.

handsontable-pro/src/plugins/filters/filters.js, line 298

filter()

Filter data based on added filter conditions.

handsontable-pro/src/plugins/filters/filters.js, line 366

getDataMapAtColumn(column){Array}

Get handsontable source data with cell meta based on current selection.

Parameters:
Name Type Description
column Number optional

Column index. By default column index accept the value of the selected column.

Returns: {Array} Returns array of objects where keys as row index.
handsontable-pro/src/plugins/filters/filters.js, line 345

getSelectedColumn(){Object|null}

Get last selected column index.

Returns: {Object|null} Return null when column isn't selected otherwise
object containing information about selected column with keys visualIndex and physicalIndex
handsontable-pro/src/plugins/filters/filters.js, line 97

isEnabled(){Boolean}

Check if the plugin is enabled in the Handsontable settings.

Returns: {Boolean}
handsontable-pro/src/plugins/filters/filters.js, line 272

removeConditions(column)

Remove conditions at specified column index.

Parameters:
Name Type Description
column Number

Visual column index.

handsontable-pro/src/plugins/filters/filters.js, line 419

restoreComponents(components)

Restore components to their cached state.

Parameters:
Name Type Description
components Array

List of components.