Skip to content

Commit 204269e

Browse files
committed
docs: add more docs about Filtering and Tree Data
1 parent 607b21e commit 204269e

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

Diff for: docs/TOC.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* [new Date Picker (vanilla-calendar)](column-functionalities/editors/date-editor-vanilla-calendar.md)
2121
* [LongText (textarea)](column-functionalities/editors/longtext-editor-textarea.md)
2222
* [Select Dropdown Editor (single/multiple)](column-functionalities/editors/select-dropdown-editor.md)
23-
* [Filters](column-functionalities/filters/README.md)
23+
* [Filters](column-functionalities/filters/filter-intro.md)
2424
* [Autocomplete](column-functionalities/filters/autocomplete-filter-kraaden-lib.md)
2525
* [Input Filter (default)](column-functionalities/filters/input-filter.md)
2626
* [Select Filter (dropdown)](column-functionalities/filters/select-filter.md)

Diff for: docs/column-functionalities/filters/filter-intro.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#### Index
2+
- [How to use Filter?](#how-to-use-filter)
3+
- [Filtering with Localization](input-filter.md#how-to-hide-filter-header-row)
4+
- [Filtering with Localization](input-filter.md#filtering-with-localization-i18n)
5+
- [Filter Complex Object](input-filter.md#how-to-filter-complex-objects)
6+
- [Update Filters Dynamically](input-filter.md#update-filters-dynamically)
7+
- [Query Different Field (Filter/Sort)](input-filter.md#query-different-field)
8+
- [Dynamic Query Field](input-filter.md#dynamic-query-field)
9+
- [Debounce/Throttle Text Search (wait for user to stop typing before filtering)](input-filter.md#debouncethrottle-text-search-wait-for-user-to-stop-typing-before-filtering)
10+
- [Ignore Locale Accent in Text Filter/Sorting](input-filter.md#ignore-locale-accent-in-text-filtersorting)
11+
- [Custom Filter Predicate](input-filter.md#custom-filter-predicate)
12+
- [Filter Shortcuts](input-filter.md#filter-shortcuts)
13+
14+
### Description
15+
16+
Filtering is a big part of a data grid, Slickgrid-Universal provides a few built-in Filters that you can use in your grids. You need to tell the grid that you want to use Filtering (via Grid Options) and you also need to enable the filter for every column that you need filtering (via Column Definitions).
17+
18+
### How to use Filter?
19+
You simply need to set the flag `filterable` for each column that you want filtering and then also enable the filters in the Grid Options. Here is an example with a full column definitions:
20+
```ts
21+
// define you columns, in this demo Effort Driven will use a Select Filter
22+
this.columnDefinitions = [
23+
{ id: 'title', name: 'Title', field: 'title' }, // without filter
24+
{ id: 'description', name: 'Description', field: 'description', filterable: true } // with filter
25+
];
26+
27+
// you also need to enable the filters in the Grid Options
28+
this.gridOptions = {
29+
enableFiltering: true
30+
};
31+
```
32+
33+
### How to hide Filter Header Row?
34+
There are 2 ways to hide Filters from the user, you could disable it completely OR you could hide the Filter Header Row.
35+
36+
##### You could disable the Filters completely,
37+
```ts
38+
angularGridReady(angularGrid: AngularGridInstance) {
39+
this.angularGrid = angularGrid;
40+
}
41+
42+
disableFilters() {
43+
this.gridOptions = {
44+
enableFiltering: false
45+
};
46+
47+
// you could re-enable it later
48+
this.angularGrid.setOptions({ enableFiltering: true });
49+
}
50+
```
51+
52+
##### You could also enable Filters but Hide them from the user in the UI
53+
This can be useful for features that require Filtering but you wish to hide the filters for example Tree Data.
54+
55+
```ts
56+
this.gridOptions = {
57+
enableFiltering: true,
58+
showHeaderRow: false,
59+
};
60+
```
61+
62+
Also, if you don't want to see the Grid Menu toggle filter row command, you should also hide it from the menu via
63+
64+
```ts
65+
angularGridReady(angularGrid: AngularGridInstance) {
66+
this.angularGrid = angularGrid;
67+
}
68+
69+
hideFilterRow() {
70+
this.gridOptions = {
71+
enableFiltering: true,
72+
showHeaderRow: false,
73+
gridMenu: {
74+
hideToggleFilterCommand: true
75+
},
76+
};
77+
78+
// you can show toggle the filter header row dynamically
79+
this.angularGrid.setHeaderRowVisibility(true);
80+
}
81+
```

Diff for: docs/grid-functionalities/Tree-Data-Grid.md renamed to docs/grid-functionalities/tree-data-grid.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515
## Description
1616
Tree Data allows you to display a hierarchical (tree) dataset into the grid, it is visually very similar to Grouping but also very different in its implementation. A hierarchical dataset is commonly used for a parent/child relation and a great example is a Bill of Material (BOM), which you can't do with Grouping because parent/child relationship could be infinite tree level while Grouping is a defined and known level of Grouping.
1717

18-
## Important Note (data mutation)
18+
## Important Notes
19+
20+
#### data mutation
1921

2022
For Tree Data to work with SlickGrid we need to **mutate** the original dataset, it will add a couple of new properties to your data, these properties are: `__treeLevel`, `__parentId` and `children` (these key names could be changed via the `treeDataOptions`). Also note that these properties become available in every Formatter (built-in and custom) which can be quite useful (especially in the tree level) in some cases... You might be thinking, could we do it without mutating the data? Probably but that would require to do a deep copy of the original data and that can be expensive on the performance side (no one it stopping you from doing a deep copy on your side though). The last thing to note is that internally for Tree Data to work, the lib always has 2 dataset (1x flat dataset and 1x hierarchical dataset which is basically a tree structure) and the lib keeps them in sync internally. So why do we do all of this? Well simply put, SlickGrid itself does not support a Tree Data structure and that is the reason we always have to keep 2 dataset structures internally because SlickGrid only works a flat dataset and nothing else.
2123

24+
25+
#### Filtering is required by Tree Data
26+
27+
Tree Data requires and uses Filters to work, you **cannot disable Filtering**. The way it works is that when you collapse a parent group, the grid is actually using Filters to filter out child rows and so expanding/collapsing groups which is why Filtering must be enabled. If you don't want to show Filters to the user, then use `showHeaderRow: false` grid option and/or toggle it from the Grid Menu. Also, if you don't want to see the Grid Menu toggle filter command, you should also hide it from the menu via `gridMenu: { hideToggleFilterCommand: true }`
28+
2229
### Demo
2330
[Demo Parent/Child Relationship](https://ghiscoding.github.io/Angular-Slickgrid/#/tree-data-parent-child) / [Component](https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-tree-data-parent-child.component.ts)
2431

0 commit comments

Comments
 (0)