@igniteui/angular-templates 21.1.14100-alpha.2 → 21.1.14100-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/SKILL.md +68 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/charts.md +457 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/data-display.md +360 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/directives.md +272 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/feedback.md +149 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/form-controls.md +313 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/layout-manager.md +420 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/layout.md +225 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-components/references/setup.md +166 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/SKILL.md +110 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/data-operations.md +445 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/editing.md +491 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/features.md +234 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/paging-remote.md +397 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/state.md +314 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/structure.md +299 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/types.md +507 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-theming/SKILL.md +439 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-theming/references/common-patterns.md +45 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-theming/references/contributing.md +471 -0
- package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-theming/references/mcp-setup.md +77 -0
- package/igx-ts/projects/_base/files/__dot__vscode/mcp.json +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
# Grid Data Operations — Sorting, Filtering & Grouping
|
|
2
|
+
|
|
3
|
+
> **Part of the [`igniteui-angular-grids`](../SKILL.md) skill hub.**
|
|
4
|
+
> For grid setup, column config — see [`structure.md`](./structure.md).
|
|
5
|
+
> For paging and remote data — see [`paging-remote.md`](./paging-remote.md).
|
|
6
|
+
> For editing and validation — see [`editing.md`](./editing.md).
|
|
7
|
+
> For state persistence — see [`state.md`](./state.md).
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- [Accessing the Grid Instance](#accessing-the-grid-instance)
|
|
12
|
+
- [Sorting](#sorting)
|
|
13
|
+
- [Filtering](#filtering)
|
|
14
|
+
- [Grouping (Flat Grid Only)](#grouping-flat-grid-only)
|
|
15
|
+
- [Key Rules](#key-rules)
|
|
16
|
+
|
|
17
|
+
## Accessing the Grid Instance
|
|
18
|
+
|
|
19
|
+
All programmatic data operations require a reference to the grid component. Use `viewChild` with the **correct component type** for your grid.
|
|
20
|
+
|
|
21
|
+
> **AGENT INSTRUCTION:** Check `package.json` to determine whether the project uses `igniteui-angular` or `@infragistics/igniteui-angular`. Replace the package prefix in every import accordingly. Always use specific entry points — never the root barrel of either package.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Component, ChangeDetectionStrategy, signal, viewChild } from '@angular/core';
|
|
25
|
+
|
|
26
|
+
// Open-source package — import from specific entry points
|
|
27
|
+
// Grid Lite (separate npm package — requires `npm install igniteui-grid-lite`)
|
|
28
|
+
import { IgxGridLiteComponent } from 'igniteui-angular/grids/lite';
|
|
29
|
+
// Flat Grid
|
|
30
|
+
import { IgxGridComponent, IGX_GRID_DIRECTIVES } from 'igniteui-angular/grids/grid';
|
|
31
|
+
// Tree Grid
|
|
32
|
+
import { IgxTreeGridComponent, IGX_TREE_GRID_DIRECTIVES } from 'igniteui-angular/grids/tree-grid';
|
|
33
|
+
// Hierarchical Grid
|
|
34
|
+
import { IgxHierarchicalGridComponent, IGX_HIERARCHICAL_GRID_DIRECTIVES } from 'igniteui-angular/grids/hierarchical-grid';
|
|
35
|
+
// Pivot Grid
|
|
36
|
+
import { IgxPivotGridComponent, IGX_PIVOT_GRID_DIRECTIVES } from 'igniteui-angular/grids/pivot-grid';
|
|
37
|
+
|
|
38
|
+
// Licensed package — same entry-point paths, different prefix:
|
|
39
|
+
// import { IgxGridComponent, IGX_GRID_DIRECTIVES } from '@infragistics/igniteui-angular/grids/grid';
|
|
40
|
+
// import { IgxTreeGridComponent, IGX_TREE_GRID_DIRECTIVES } from '@infragistics/igniteui-angular/grids/tree-grid';
|
|
41
|
+
// import { IgxHierarchicalGridComponent, IGX_HIERARCHICAL_GRID_DIRECTIVES } from '@infragistics/igniteui-angular/grids/hierarchical-grid';
|
|
42
|
+
// import { IgxPivotGridComponent, IGX_PIVOT_GRID_DIRECTIVES } from '@infragistics/igniteui-angular/grids/pivot-grid';
|
|
43
|
+
|
|
44
|
+
// AVOID — never import from the root barrel (wrong for BOTH variants)
|
|
45
|
+
// import { IgxGridComponent } from 'igniteui-angular';
|
|
46
|
+
// import { IgxGridComponent } from '@infragistics/igniteui-angular';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Flat Grid Example
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
@Component({
|
|
53
|
+
selector: 'app-orders-grid',
|
|
54
|
+
imports: [IGX_GRID_DIRECTIVES],
|
|
55
|
+
templateUrl: './orders-grid.component.html',
|
|
56
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
57
|
+
})
|
|
58
|
+
export class OrdersGridComponent {
|
|
59
|
+
gridRef = viewChild.required<IgxGridComponent>('grid');
|
|
60
|
+
protected data = signal<Order[]>([]);
|
|
61
|
+
|
|
62
|
+
sortByName() {
|
|
63
|
+
this.gridRef().sort({ fieldName: 'name', dir: SortingDirection.Asc, ignoreCase: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Tree Grid Example
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
@Component({
|
|
72
|
+
selector: 'app-org-tree',
|
|
73
|
+
imports: [IGX_TREE_GRID_DIRECTIVES],
|
|
74
|
+
templateUrl: './org-tree.component.html',
|
|
75
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
76
|
+
})
|
|
77
|
+
export class OrgTreeComponent {
|
|
78
|
+
// Use IgxTreeGridComponent for tree grids
|
|
79
|
+
treeGridRef = viewChild.required<IgxTreeGridComponent>('treeGrid');
|
|
80
|
+
protected employees = signal<Employee[]>([]);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<igx-tree-grid #treeGrid
|
|
86
|
+
[data]="employees()"
|
|
87
|
+
primaryKey="id"
|
|
88
|
+
foreignKey="managerId"
|
|
89
|
+
height="600px">
|
|
90
|
+
<igx-column field="name" [sortable]="true" [filterable]="true"></igx-column>
|
|
91
|
+
</igx-tree-grid>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Hierarchical Grid Example
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
@Component({
|
|
98
|
+
selector: 'app-company-grid',
|
|
99
|
+
imports: [IGX_HIERARCHICAL_GRID_DIRECTIVES],
|
|
100
|
+
templateUrl: './company-grid.component.html',
|
|
101
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
102
|
+
})
|
|
103
|
+
export class CompanyGridComponent {
|
|
104
|
+
// Use IgxHierarchicalGridComponent for hierarchical grids
|
|
105
|
+
hGridRef = viewChild.required<IgxHierarchicalGridComponent>('hGrid');
|
|
106
|
+
protected companies = signal<Company[]>([]);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<igx-hierarchical-grid #hGrid
|
|
112
|
+
[data]="companies()"
|
|
113
|
+
primaryKey="id"
|
|
114
|
+
height="600px">
|
|
115
|
+
<igx-column field="name" [sortable]="true"></igx-column>
|
|
116
|
+
<igx-row-island key="orders" primaryKey="orderId">
|
|
117
|
+
<igx-column field="orderId" [sortable]="true"></igx-column>
|
|
118
|
+
</igx-row-island>
|
|
119
|
+
</igx-hierarchical-grid>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
> **CRITICAL**: Every programmatic example in this file uses Flat Grid (`IgxGridComponent`) by default. For Tree Grid substitute `IgxTreeGridComponent` and `#treeGrid`. For Hierarchical Grid substitute `IgxHierarchicalGridComponent` and `#hGrid`. The sorting, filtering, and editing APIs are either the same or very similar across all three grid types (Flat, Tree, Hierarchical). **Pivot Grid does NOT support standard sorting/filtering/editing APIs** — see [`state.md`](./state.md). **Grid Lite has its own lightweight sorting/filtering API** — see [`state.md`](./state.md).
|
|
123
|
+
|
|
124
|
+
## Sorting
|
|
125
|
+
|
|
126
|
+
> **Docs:** [Sorting](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/sorting) · [Tree Grid](https://www.infragistics.com/products/ignite-ui-angular/angular/components/treegrid/sorting) · [Hierarchical Grid](https://www.infragistics.com/products/ignite-ui-angular/angular/components/hierarchicalgrid/sorting)
|
|
127
|
+
|
|
128
|
+
> **Applies to**: Flat Grid, Tree Grid, and Hierarchical Grid. Pivot Grid uses dimension-level sorting instead (see [`state.md`](./state.md)). **Grid Lite** uses a different sorting API — see [`state.md`](./state.md).
|
|
129
|
+
>
|
|
130
|
+
> **Tree Grid behavior**: sorting is applied per-level — children are sorted among their siblings, not globally flattened.
|
|
131
|
+
>
|
|
132
|
+
> **Hierarchical Grid behavior**: each grid level sorts independently. Configure sorting on the `<igx-row-island>` to apply to all child grids at that level.
|
|
133
|
+
|
|
134
|
+
### Template-Driven Sorting
|
|
135
|
+
|
|
136
|
+
Enable sorting on individual columns and optionally bind the sorting state:
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<igx-grid #grid
|
|
140
|
+
[data]="data()"
|
|
141
|
+
[(sortingExpressions)]="sortExprs"
|
|
142
|
+
[sortingOptions]="{ mode: 'single' }">
|
|
143
|
+
<igx-column field="name" [sortable]="true"></igx-column>
|
|
144
|
+
<igx-column field="date" dataType="date" [sortable]="true"></igx-column>
|
|
145
|
+
<igx-column field="amount" dataType="number" [sortable]="true"></igx-column>
|
|
146
|
+
</igx-grid>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Sorting modes:
|
|
150
|
+
- `'multiple'` — multi-column sorting in order (default)
|
|
151
|
+
- `'single'` — only one column sorted at a time
|
|
152
|
+
|
|
153
|
+
### Programmatic Sorting
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { SortingDirection } from 'igniteui-angular/core';
|
|
157
|
+
// import { SortingDirection } from '@infragistics/igniteui-angular/core'; for licensed package
|
|
158
|
+
|
|
159
|
+
// Sort a single column
|
|
160
|
+
this.gridRef().sort({ fieldName: 'name', dir: SortingDirection.Asc, ignoreCase: true });
|
|
161
|
+
|
|
162
|
+
// Sort multiple columns
|
|
163
|
+
this.gridRef().sort([
|
|
164
|
+
{ fieldName: 'category', dir: SortingDirection.Asc, ignoreCase: true },
|
|
165
|
+
{ fieldName: 'price', dir: SortingDirection.Desc, ignoreCase: false }
|
|
166
|
+
]);
|
|
167
|
+
|
|
168
|
+
// Clear sorting on one column
|
|
169
|
+
this.gridRef().clearSort('name');
|
|
170
|
+
|
|
171
|
+
// Clear all sorting
|
|
172
|
+
this.gridRef().clearSort();
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Sorting Events
|
|
176
|
+
|
|
177
|
+
| Event | Cancelable | Payload |
|
|
178
|
+
|---|---|---|
|
|
179
|
+
| `(sorting)` | Yes | `ISortingEventArgs` — set `event.cancel = true` to prevent |
|
|
180
|
+
| `(sortingDone)` | No | `ISortingEventArgs` — fires after sort is applied |
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
onSorting(event: ISortingEventArgs) {
|
|
184
|
+
// Prevent sorting on a specific column
|
|
185
|
+
if (event.fieldName === 'id') {
|
|
186
|
+
event.cancel = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
onSortingDone(event: ISortingEventArgs) {
|
|
191
|
+
console.log('Sorted by:', event.fieldName, event.dir);
|
|
192
|
+
// Good place to trigger remote data fetch
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Custom Sorting Strategy
|
|
197
|
+
|
|
198
|
+
Implement `ISortingStrategy` to control how values are compared:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import { ISortingStrategy, SortingDirection } from 'igniteui-angular/core';
|
|
202
|
+
|
|
203
|
+
class PrioritySortStrategy implements ISortingStrategy {
|
|
204
|
+
private priorityOrder = ['Critical', 'High', 'Medium', 'Low'];
|
|
205
|
+
|
|
206
|
+
sort(data: any[], fieldName: string, dir: SortingDirection): any[] {
|
|
207
|
+
return data.sort((a, b) => {
|
|
208
|
+
const indexA = this.priorityOrder.indexOf(a[fieldName]);
|
|
209
|
+
const indexB = this.priorityOrder.indexOf(b[fieldName]);
|
|
210
|
+
return dir === SortingDirection.Asc ? indexA - indexB : indexB - indexA;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
```html
|
|
217
|
+
<igx-column field="priority" [sortable]="true" [sortStrategy]="prioritySortStrategy"></igx-column>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Filtering
|
|
221
|
+
|
|
222
|
+
> **Docs:** [Filtering](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/filtering) · [Excel-Style](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/excel-style-filtering) · [Advanced](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/advanced-filtering) (substitute URL prefix per grid type)
|
|
223
|
+
|
|
224
|
+
> **Applies to**: Flat Grid, Tree Grid, and Hierarchical Grid. Pivot Grid uses dimension-level filtering instead (see [`state.md`](./state.md)). **Grid Lite** uses a different filtering API — see [`state.md`](./state.md).
|
|
225
|
+
>
|
|
226
|
+
> **Tree Grid behavior**: filtering is **recursive** — when a child matches, all its ancestor rows are shown (even if they don't match) and auto-expanded.
|
|
227
|
+
>
|
|
228
|
+
> **Hierarchical Grid behavior**: each grid level filters independently. Configure filtering on the `<igx-row-island>` to apply to all child grids at that level.
|
|
229
|
+
|
|
230
|
+
### Filter Modes
|
|
231
|
+
|
|
232
|
+
| Mode | Template Property | Description |
|
|
233
|
+
|---|---|---|
|
|
234
|
+
| Quick Filter | `[filterMode]="'quickFilter'"` | Row of filter inputs above columns |
|
|
235
|
+
| Excel-Style | `[filterMode]="'excelStyleFilter'"` | Excel-like dropdown menus per column |
|
|
236
|
+
| Advanced | `[allowAdvancedFiltering]="true"` | Dialog with complex filter tree (AND/OR groups) |
|
|
237
|
+
|
|
238
|
+
```html
|
|
239
|
+
<!-- Excel-style filtering (most common enterprise pattern) -->
|
|
240
|
+
<igx-grid #grid
|
|
241
|
+
[data]="data()"
|
|
242
|
+
[allowFiltering]="true"
|
|
243
|
+
[filterMode]="'excelStyleFilter'">
|
|
244
|
+
<igx-column field="name" [filterable]="true"></igx-column>
|
|
245
|
+
<igx-column field="status" [filterable]="true"></igx-column>
|
|
246
|
+
<igx-column field="amount" dataType="number" [filterable]="true"></igx-column>
|
|
247
|
+
</igx-grid>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Programmatic Filtering
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
import {
|
|
254
|
+
IgxStringFilteringOperand,
|
|
255
|
+
IgxNumberFilteringOperand,
|
|
256
|
+
IgxDateFilteringOperand,
|
|
257
|
+
IgxBooleanFilteringOperand,
|
|
258
|
+
FilteringExpressionsTree,
|
|
259
|
+
FilteringLogic
|
|
260
|
+
} from 'igniteui-angular/core';
|
|
261
|
+
// import { ... } from '@infragistics/igniteui-angular/core'; for licensed package
|
|
262
|
+
|
|
263
|
+
// Simple single-column filter
|
|
264
|
+
this.gridRef().filter('name', 'John', IgxStringFilteringOperand.instance().condition('contains'), true);
|
|
265
|
+
|
|
266
|
+
// Filter by number range
|
|
267
|
+
this.gridRef().filter('amount', 1000, IgxNumberFilteringOperand.instance().condition('greaterThan'));
|
|
268
|
+
|
|
269
|
+
// Filter by date
|
|
270
|
+
this.gridRef().filter('hireDate', new Date(2024, 0, 1), IgxDateFilteringOperand.instance().condition('after'));
|
|
271
|
+
|
|
272
|
+
// Clear single column filter
|
|
273
|
+
this.gridRef().clearFilter('name');
|
|
274
|
+
|
|
275
|
+
// Clear all filters
|
|
276
|
+
this.gridRef().clearFilter();
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Complex Filtering (AND/OR Groups)
|
|
280
|
+
|
|
281
|
+
Build multi-condition filters using `FilteringExpressionsTree`:
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
const tree = new FilteringExpressionsTree(FilteringLogic.And);
|
|
285
|
+
tree.filteringOperands = [
|
|
286
|
+
{
|
|
287
|
+
fieldName: 'status',
|
|
288
|
+
condition: IgxStringFilteringOperand.instance().condition('equals'),
|
|
289
|
+
searchVal: 'Active',
|
|
290
|
+
ignoreCase: true
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
fieldName: 'amount',
|
|
294
|
+
condition: IgxNumberFilteringOperand.instance().condition('greaterThan'),
|
|
295
|
+
searchVal: 500
|
|
296
|
+
}
|
|
297
|
+
];
|
|
298
|
+
// Use filteringExpressionsTree for column-level programmatic filtering
|
|
299
|
+
this.gridRef().filteringExpressionsTree = tree;
|
|
300
|
+
this.gridRef().cdr.detectChanges();
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
> **NOTE**: Use `filteringExpressionsTree` for programmatic column-level filtering. `advancedFilteringExpressionsTree` is only for the advanced filtering dialog (`[allowAdvancedFiltering]="true"`).
|
|
304
|
+
|
|
305
|
+
### Global Filtering & Cross-Column Logic
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
// Filter all filterable columns at once with a search term
|
|
309
|
+
this.gridRef().filterGlobal('search term', IgxStringFilteringOperand.instance().condition('contains'), true);
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Control the AND/OR logic between **different column** filters:
|
|
313
|
+
|
|
314
|
+
```html
|
|
315
|
+
<!-- Default is AND — all column filters must match. Use OR to match any column filter -->
|
|
316
|
+
<igx-grid #grid [data]="data()" [allowFiltering]="true" [filteringLogic]="filteringLogic">
|
|
317
|
+
</igx-grid>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
import { FilteringLogic } from 'igniteui-angular';
|
|
322
|
+
|
|
323
|
+
// FilteringLogic.And (default) — row must match ALL column filters
|
|
324
|
+
// FilteringLogic.Or — row must match ANY column filter
|
|
325
|
+
filteringLogic = FilteringLogic.And;
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Filtering Events
|
|
329
|
+
|
|
330
|
+
| Event | Cancelable | Payload |
|
|
331
|
+
|---|---|---|
|
|
332
|
+
| `(filtering)` | Yes | `IFilteringEventArgs` — set `event.cancel = true` to prevent |
|
|
333
|
+
| `(filteringDone)` | No | `IFilteringEventArgs` — fires after a **column-level** filter is applied |
|
|
334
|
+
| `(filteringExpressionsTreeChange)` | No | `IFilteringExpressionsTree` — fires after the **grid-level** filter tree changes (use this for remote data) |
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
onFilteringDone(event: IFilteringEventArgs) {
|
|
338
|
+
// Trigger remote data fetch with new filter state
|
|
339
|
+
this.loadFilteredData();
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
> **Remote data note:** For remote filtering, subscribe to `(filteringExpressionsTreeChange)` instead of `(filteringDone)`. The former reflects the complete grid-level filter tree, including "clear all filters" — `filteringDone` is column-scoped and can miss global state changes.
|
|
344
|
+
|
|
345
|
+
### Available Filtering Operands by Data Type
|
|
346
|
+
|
|
347
|
+
| Operand Class | Conditions |
|
|
348
|
+
|---|---|
|
|
349
|
+
| `IgxStringFilteringOperand` | `contains`, `startsWith`, `endsWith`, `equals`, `doesNotEqual`, `doesNotContain`, `empty`, `notEmpty`, `null`, `notNull`, `in` |
|
|
350
|
+
| `IgxNumberFilteringOperand` | `equals`, `doesNotEqual`, `greaterThan`, `lessThan`, `greaterThanOrEqualTo`, `lessThanOrEqualTo`, `empty`, `notEmpty`, `null`, `notNull`, `in` |
|
|
351
|
+
| `IgxDateFilteringOperand` | `equals`, `doesNotEqual`, `before`, `after`, `today`, `yesterday`, `thisMonth`, `lastMonth`, `nextMonth`, `thisYear`, `lastYear`, `nextYear`, `empty`, `notEmpty`, `null`, `notNull`, `in` |
|
|
352
|
+
| `IgxBooleanFilteringOperand` | `all`, `true`, `false`, `empty`, `notEmpty`, `null`, `notNull` |
|
|
353
|
+
|
|
354
|
+
## Grouping (Flat Grid Only)
|
|
355
|
+
|
|
356
|
+
> **Docs:** [Group By](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/groupby)
|
|
357
|
+
|
|
358
|
+
> **NOTE**: GroupBy is **exclusive to the Flat Grid** (`igx-grid`). Tree Grid uses its natural hierarchy. Hierarchical Grid uses row islands. Pivot Grid uses dimensions.
|
|
359
|
+
|
|
360
|
+
### Template-Driven Grouping
|
|
361
|
+
|
|
362
|
+
```html
|
|
363
|
+
<igx-grid #grid
|
|
364
|
+
[data]="data()"
|
|
365
|
+
[groupsExpanded]="true">
|
|
366
|
+
<igx-column field="category" [groupable]="true"></igx-column>
|
|
367
|
+
<igx-column field="product" [groupable]="true"></igx-column>
|
|
368
|
+
<igx-column field="price" dataType="number"></igx-column>
|
|
369
|
+
|
|
370
|
+
<!-- Custom group row template -->
|
|
371
|
+
<ng-template igxGroupByRow let-groupRow>
|
|
372
|
+
{{ groupRow.expression.fieldName }}: {{ groupRow.value }}
|
|
373
|
+
({{ groupRow.records.length }} items)
|
|
374
|
+
</ng-template>
|
|
375
|
+
</igx-grid>
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Programmatic Grouping
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
import { SortingDirection } from 'igniteui-angular/core';
|
|
382
|
+
|
|
383
|
+
// Group by a column
|
|
384
|
+
this.gridRef().groupBy({ fieldName: 'category', dir: SortingDirection.Asc, ignoreCase: true });
|
|
385
|
+
|
|
386
|
+
// Group by multiple columns
|
|
387
|
+
this.gridRef().groupBy([
|
|
388
|
+
{ fieldName: 'region', dir: SortingDirection.Asc, ignoreCase: true },
|
|
389
|
+
{ fieldName: 'category', dir: SortingDirection.Asc, ignoreCase: true }
|
|
390
|
+
]);
|
|
391
|
+
|
|
392
|
+
// Clear grouping on one column
|
|
393
|
+
this.gridRef().clearGrouping('category');
|
|
394
|
+
|
|
395
|
+
// Clear all grouping
|
|
396
|
+
this.gridRef().clearGrouping();
|
|
397
|
+
|
|
398
|
+
// Toggle group row expansion
|
|
399
|
+
this.gridRef().toggleGroup(groupRow);
|
|
400
|
+
|
|
401
|
+
// Expand/collapse all groups
|
|
402
|
+
this.gridRef().toggleAllGroupRows();
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Group By Events
|
|
406
|
+
|
|
407
|
+
| Event | Description |
|
|
408
|
+
|---|---|
|
|
409
|
+
| `(groupingDone)` | Fires after grouping expressions change |
|
|
410
|
+
|
|
411
|
+
### Custom Group-By Key
|
|
412
|
+
|
|
413
|
+
Control how values are grouped using a `groupingComparer`:
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
// Group dates by month instead of exact value
|
|
417
|
+
const monthGroupComparer = (a: Date, b: Date) => {
|
|
418
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() ? 0 : -1;
|
|
419
|
+
};
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
```html
|
|
423
|
+
<igx-column field="orderDate" dataType="date" [groupable]="true" [groupingComparer]="monthGroupComparer"></igx-column>
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## Key Rules
|
|
427
|
+
|
|
428
|
+
1. **Use the correct component type for `viewChild`** — `IgxGridLiteComponent`, `IgxGridComponent`, `IgxTreeGridComponent`, `IgxHierarchicalGridComponent`, or `IgxPivotGridComponent`
|
|
429
|
+
2. **Import the correct directives/components** — `IGX_GRID_DIRECTIVES`, `IGX_TREE_GRID_DIRECTIVES`, `IGX_HIERARCHICAL_GRID_DIRECTIVES`, `IGX_PIVOT_GRID_DIRECTIVES`, or individual Grid Lite imports (with `CUSTOM_ELEMENTS_SCHEMA`)
|
|
430
|
+
3. **Set `dataType` on every column** — enables correct filtering operands, sorting behavior, and editors
|
|
431
|
+
4. **Cancelable events** — use `event.cancel = true` in `(sorting)`, `(filtering)` to prevent the action
|
|
432
|
+
5. **Use signals for data** — `[data]="myData()"` with `signal<T[]>([])`
|
|
433
|
+
6. **GroupBy is Flat Grid only** — Tree Grid uses hierarchy, Hierarchical Grid uses row islands, Pivot Grid uses dimensions
|
|
434
|
+
7. **Tree Grid filtering is recursive** — parents of matching children are always shown and auto-expanded
|
|
435
|
+
8. **Hierarchical Grid levels are independent** — sorting/filtering don't cascade; configure on `<igx-row-island>`
|
|
436
|
+
9. **Use `filteringExpressionsTree` for programmatic filtering** — `advancedFilteringExpressionsTree` is only for the advanced filtering dialog
|
|
437
|
+
|
|
438
|
+
## See Also
|
|
439
|
+
|
|
440
|
+
- [`paging-remote.md`](./paging-remote.md) — Paging, remote data operations, virtualization, multi-grid coordination
|
|
441
|
+
- [`editing.md`](./editing.md) — Cell editing, row editing, batch editing, validation, summaries
|
|
442
|
+
- [`state.md`](./state.md) — State persistence, Tree Grid / Hierarchical Grid / Pivot Grid / Grid Lite data operations
|
|
443
|
+
- [`structure.md`](./structure.md) — Grid structure, column configuration, templates, layout, selection
|
|
444
|
+
- [`../../igniteui-angular-components/SKILL.md`](../../igniteui-angular-components/SKILL.md) — Non-grid Ignite UI components
|
|
445
|
+
- [`../../igniteui-angular-theming/SKILL.md`](../../igniteui-angular-theming/SKILL.md) — Theming & Styling
|