ValueFilter Class
File
wijmo.grid.filter.js
Module
wijmo.grid.filter
Derived Classes
FlexSheetValueFilter
Implements
IColumnFilter

Defines a value filter for a column on a FlexGrid control.

Value filters contain an explicit list of values that should be displayed by the grid.

Constructor

constructor

constructor(column: Column): ValueFilter

Initializes a new instance of the ValueFilter class.

Parameters
  • column: Column

    The column to filter.

Returns
ValueFilter

Properties

column

Gets the Column to filter.

Type
Column

dataMap

Gets or sets the DataMap used to convert raw values into display values shown when editing this filter.

Type
DataMap

exclusiveValueSearch

Gets or sets a value that determines whether the filter should include only values selected by the filterText property.

The default value for this property is **true**, which matches Excel's behavior.

Set it to **false** to disable this behavior, so searching only affects which items are displayed on the list and not which items are included in the filter.

Type
boolean

filterText

Gets or sets a string used to filter the list of display values.

Type
string

isActive

Gets a value that indicates whether the filter is active.

The filter is active if some values are selected and some are not. If all values are in the same state (either selected or un-selected), then the filter is not active.

Type
boolean

maxValues

Gets or sets the maximum number of elements on the list of display values.

Adding too many items to the list makes searching difficult and hurts performance. This property limits the number of items displayed at any time, but users can still use the search box to filter the items they are interested in.

The default value for this property is **250**.

This code changes the value to 1,000,000, effectively listing all unique values for the field:

import { FlexGridFilter} from '@mescius/wijmo.grid.filter';

// change the maxItems property for the 'id' column: let f = new FlexGridFilter(theGrid); f.getColumnFilter('id').valueFilter.maxValues = 1000000;

Type
number

searchType

Gets or sets the search type to use for ValueFilterEditor.

For example, the code below sets up the ValueFilter for 'country' column to use Excel style wildcards

import { FlexGridFilter, ValueFilterSearchKind } from '@mescius/wijmo.grid.filter';
let filter = new FlexGridFilter(flex);
filter.getColumnFilter("country").valueFilter.searchType = ValueFilterSearchKind.Excel;

The default value for this property is **ValueFilterSearchKind.Excel**.

Type
ValueFilterSearchKind

showValues

Gets or sets an object with the selected (checked) values on the value list.

If the filter is not active, this property is set to null and all values present in the data source are shown on the list.

If the filter is active (the user selected some values from the list but not all), the showValues property is set to an object whose property names are the display values of the selected values.

For example, if the value list contains country names and the user selected "US" and "Japan", the showValues property returns:

```javascript { Japan: true, US: true } ```

Type
any

sortValues

Gets or sets a value that determines whether the values should be sorted when displayed in the editor.

This property is especially useful when you are using the uniqueValues to provide a custom list of values property and you would like to preserve the order of the values.

Type
boolean

uniqueValues

Gets or sets an array containing the unique values to be displayed on the list.

If this property is set to null, the list will be filled based on the grid data.

Explicitly assigning the list of unique values is more efficient than building the list from the data, and is required for value filters to work properly when the data is filtered on the server (because in this case some values might not be present on the client so the list will be incomplete).

By default, the filter editor will sort the unique values when displaying them to the user. If you want to prevent that and show the values in the order you provided, set the sortValues property to false.

For example, the code below provides a list of countries to be used in the ValueFilter for the column bound to the 'country' field:

import { FlexGridFilter} from '@mescius/wijmo.grid.filter';

// create filter for a FlexGrid let filter = new FlexGridFilter(grid);
// assign list of unique values to country filter let cf = filter.getColumnFilter('country'); cf.valueFilter.uniqueValues = ['Austria', 'Belgium', 'Chile', 'Denmark'];

Type
any[]

Methods

apply

apply(value): boolean

Gets a value that indicates whether a value passes the filter.

Parameters
  • value:

    The value to test.

Returns
boolean

clear

clear(): void

Clears the filter.

Returns
void

getUniqueValues

getUniqueValues(filtered?: boolean): any[]

Gets an array containing objects that represent all unique values for this column.

The objects in the array returned contain two properties: *value* (the data value) and *text* (the formatted data value).

If the uniqueValues property is set to an array of values, that array is used as a data source.

If uniqueValues is null, the method scans all items in the data source and returns an creates an array containing all unique values.

This method is used by the ValueFilterEditor class to populate the list of values shown to users.

Parameters
  • filtered: boolean Optional

    Whether to apply all other filters when retrieving the values from the data source.

Returns
any[]

implementsInterface

implementsInterface(interfaceName: string): boolean

Returns true if this object supports a given interface.

Parameters
  • interfaceName: string

    Name of the interface to look for.

Returns
boolean