-
-
Notifications
You must be signed in to change notification settings - Fork 29
Compound Filters
Compound filters are a combination of 2 elements (Operator Select + Input Filter) used as a filter on a column. This is very useful to make it obvious to the user that there are Operator available and even more useful with a date picker (Flatpickr
).
There are multiple types of compound filters available
-
Filters.compoundInputText
adds an Operator combine to an Input of typetext
(alias toFilters.compoundInput
). -
Filters.compoundInputNumber
adds an Operator combine to an Input of typenumber
. -
Filters.compoundInputPassword
adds an Operator combine to an Input of type `password. -
Filters.compoundDate
adds an Operator combine to a Date Picker (flatpickr). -
Filters.compoundSlider
adds an Operator combine to a Slider Filter.
You can change the $flatpickr-bgcolor
and any of the $compound-filter-X
SASS variables for styling. For more info on how to use SASS in your project, read the Wiki - Styling
Simply set the flag filterable
to True and use the filter type Filters.compoundInput
. Here is an example with a full column definition:
// define you columns, in this demo Effort Driven will use a Select Filter
this.columnDefinitions = [
{ id: 'title', name: 'Title', field: 'title' },
{ id: 'description', name: 'Description', field: 'description', filterable: true },
{ id: 'complete', name: '% Complete', field: 'percentComplete',
formatter: Formatters.percentCompleteBar,
type: 'number',
filterable: true,
filter: { model: Filters.compoundInput }
}
];
// you also need to enable the filters in the Grid Options
this.gridOptions = {
enableFiltering: true
};
The column definition type
will affect the list of Operators shown, for example if you have type: FieldType.string
, it will display the operators (=
, a*
, *z
) where a*
means StartsWith and *z
means EndsWith. The current logic implemented is that any types that are not String, will display the list of Operators (
, =
, <
, <=
, >
, >=
, <>
)
Again set the column definition flag filterable: true
and use the filter type Filters.compoundDate
. Here is an example with a full column definition:
// define you columns, in this demo Effort Driven will use a Select Filter
this.columnDefinitions = [
{ id: 'title', name: 'Title', field: 'title' },
{ id: 'description', name: 'Description', field: 'description', filterable: true },
{ id: 'usDateShort', name: 'US Date Short', field: 'usDateShort',
type: 'dateUsShort',
filterable: true,
filter: {
model: Filters.compoundDate,
// you can also add an optional placeholder
placeholder: 'filter by date'
}
}
];
// you also need to enable the filters in the Grid Options
this.gridOptions = {
enableFiltering: true
};
What if your date input (from your dataset) has a different output on the screen (UI)?
In that case, you will most probably have a Formatter and type representing the input type, we also provided an outputType
that can be used to deal with that case.
For example, if we have an input date in UTC format and we want to display a Date ISO format to the screen (UI) in the date picker.
// define you columns, in this demo Effort Driven will use a Select Filter
this.columnDefinitions = [
{ id: 'title', name: 'Title', field: 'title' },
{ id: 'description', name: 'Description', field: 'description', filterable: true },
{ id: 'utcDate', name: 'UTC Date', field: 'utcDate',
type: 'dateUtc', // format used in the dataset (input)
formatter: Formatters.dateTimeIso, // format to show in the cell on each row (formatter)
outputType: 'dateTimeIso', // format to show in the date picker
filterable: true, filter: { model: Filters.compoundDate }
}
];
// you also need to enable the filters in the Grid Options
this.gridOptions = {
enableFiltering: true
};
The date picker will automatically detect if the type
or outputType
has time inside, if it does then it will add a time picker at the bottom of the date picker.
For example, if we have an input date in UTC format and we want to display a Date ISO format with time to the screen (UI) and the date picker.
// define you columns, in this demo Effort Driven will use a Select Filter
this.columnDefinitions = [
{ id: 'title', name: 'Title', field: 'title' },
{ id: 'description', name: 'Description', field: 'description', filterable: true },
{ id: 'utcDate', name: 'UTC Date', field: 'utcDate',
type: 'dateUtc',
formatter: Formatters.dateTimeIsoAmPm,
outputType: 'dateTimeIsoAmPm',
filterable: true, filter: { model: Filters.compoundDate }
}
];
// you also need to enable the filters in the Grid Options
this.gridOptions = {
enableFiltering: true
};
All the available options that can be provided as filterOptions
to your column definitions can be found under this FlatpickrOption interface and you should cast your filterOptions
to that interface to make sure that you use only valid options of the Flatpickr library.
filter: {
model: Filters.compoundDate,
filterOptions: {
minDate: 'today'
} as FlatpickrOption
}
- Slickgrid-Universal Wikis
- Installation
- Styling
- Interfaces/Models
- Column Functionalities
- Events
- Grid Functionalities
- Auto-Resize / Resizer Service
- Resize by Cell Content
- Column Picker
- Composite Editor Modal
- Custom Tooltip
- Context Menu
- Custom Footer
- Export to Excel
- Export to File (csv/txt)
- Grid Menu
- Grid State & Presets
- Grouping & Aggregators
- Header Menu & Header Buttons
- Pinning (frozen) of Columns/Rows
- Row Selection
- Tree Data Grid
- SlickGrid & DataView objects
- Backend Services