[]
Initializes a new instance of the FlexGridFilter class.
The FlexGrid to filter.
Initialization options for the FlexGridFilter.
Gets the active ColumnFilterEditor.
This property allows you to customize the filter editor when handling the filterChanging event. It returns null when no filters are being edited.
Gets or sets the default filter type to use.
This value can be overridden in filters for specific columns. For example, the code below creates a filter that filters by conditions on all columns except the "ByValue" column:
import { FlexGridFilter, FilterType } from '@mescius/wijmo.grid.filter';
let filter = new FlexGridFilter(flex);
filter.defaultFilterType = FilterType.Condition;
let col = flex.getColumn('ByValue'),
cf = filter.getColumnFilter(col);
cf.filterType = FilterType.Value;
The default value for this property is FilterType.Both.
Gets or sets a value that determines whether the filter should include only values selected by the ValueFilter.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.
Gets or sets an array containing the names or bindings of the columns that have filters.
Setting this property to null or to an empty array adds filters to all columns.
Gets or sets the current filter definition as a JSON string.
The filterDefinition includes information about all currently active column filters. It does not include data maps because data maps are not serializable.
Gets a reference to the FlexGrid that owns this filter.
Gets or sets a value indicating whether to apply filter on the updated rows. If this property is set to true, then events such as row update, row insertion, sorting etc refreshes filter and rows which do not pass filter gets filtered out. If this property is set to false, then filter is not applied immediately and we need to click the apply button again to refresh filter. For complete excel behavior you also need to set the refreshOnEdit property CollectionView.refreshOnEdit of CollectionView to false
// For flexgrid
flexgrid.collectionView.refreshOnEdit = false;
// For flexsheet
flexSheet.itemsSourceChanged.addHandler((s, e) => {
if(s.collectionView){
s.collectionView.refreshOnEdit = false;
}
});
The default value for this property is false.
Gets or sets a value indicating whether the FlexGridFilter adds filter editing buttons to the grid's column headers.
If you set this property to false, then you are responsible for providing a way for users to edit, clear, and apply the filters.
The default value for this property is true.
Gets or sets a value indicating whether the filter editor should include sort buttons.
By default, the editor shows sort buttons like Excel does. But since users can sort columns by clicking their headers, sort buttons in the filter editor may not be desirable in some circumstances.
The default value for this property is true.
Applies the current column filters to the grid.
Clears all column filters.
Closes the filter editor.
Shows the filter editor for the given grid column.
The Column that contains the filter to edit.
A wijmo.grid.HitTestInfo object containing the range of the cell that triggered the filter display.
An HTMLElement to use as a reference for positioning the editor.
Gets the filter for the given column.
The Column that the filter applies to (or column name or index). If the specified column does not exist, the method returns null.
Whether to create the filter if it does not exist.
Raises the editingFilter event.
CellRangeEventArgs that contains the event data.
True if the event was not canceled.
Raises the exclusiveValueSearchChanged event.
Raises the filterApplied event.
Raises the filterChanged event.
Raises the filterChanging event.
CellRangeEventArgs that contains the event data.
True if the event was not canceled.
Occurs when a column filter is about to be edited by the user. Use this event to customize the column filter if you want to override the default settings for the filter.
This event fires before the filter editor is created, so the activeEditor property is null at this point. If you want to customize the editor, use the filterChanging event.
For example, the code below customizes the list of country names in the value filter editor so "Italy" is always the first value:
new FlexGridFilter(theGrid, {
editingFilter: (s, e) => {
if (e.getColumn().binding == 'country') {
// start with Italy
let vals = ["Italy"];
// append other unique values (except Italy)
let valueFilter = s.getColumnFilter("country", true).valueFilter;
valueFilter.uniqueValues = null;
valueFilter.getUniqueValues().forEach(item => {
if (item.text != "Italy") {
vals.push(item.text);
}
});
// assign custom unique value list to the valueFilter
valueFilter.uniqueValues = vals;
valueFilter.sortValues = false;
}
}
});
Occurs after the exclusiveValueSearch is changed.
Occurs after the filter is applied.
Occurs after a column filter has been edited by the user.
Use the event parameters to determine the column that owns the filter and whether changes were applied or canceled.
Occurs when a column filter is about to be edited by the user.
Use this event to customize the filter editor if you want to override its default settings. You can use the activeEditor property to get a reference to the currently active filter editor.
For example, the code below applies a custom sort to the list of country names in the value filter editor so "Italy" is always the first value:
new FlexGridFilter(theGrid, {
filterChanging: (s, e) => {
if (e.getColumn().binding == "country") {
let edt = s.activeEditor,
lbHost = edt.hostElement.querySelector('[wj-part=div-values]'),
lb = Control.getControl(lbHost) as ListBox;
(lb.collectionView as CollectionView).sortComparer = (a: any, b: any) => {
if (a != b) { // sort Italy first
if (a == 'Italy') return -1;
if (b == 'Italy') return +1;
}
return null; // use default sort order
}
lb.collectionView.refresh();
}
},
});
Implements an Excel-style filter for FlexGrid controls.
To enable filtering on a FlexGrid control, create an instance of the FlexGridFilter and pass the grid as a parameter to the constructor. For example:
import { FlexGrid } from '@mescius/wijmo.grid'; import { FlexGridFilter } from '@mescius/wijmo.grid.filter'; let flex = new FlexGrid('#theGrid'); // create the grid let filter = new FlexGridFilter(flex); // add a filter to the grid
Once this is done, a filter icon is added to the grid's column headers. Clicking the icon shows an editor where the user can edit the filter conditions for that column.
The FlexGridFilter class depends on the wijmo.grid and wijmo.input modules.
The example below shows how you can use a FlexGridFilter to add filtering to a FlexGrid control:
Example