@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
package/igx-ts/projects/_base/files/__dot__claude/skills/igniteui-angular-grids/references/state.md
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# Grid State Persistence & Grid-Type-Specific Operations
|
|
2
|
+
|
|
3
|
+
> **Part of the [`igniteui-angular-grids`](../SKILL.md) skill hub.**
|
|
4
|
+
> For grid import patterns and `viewChild` access — see [`data-operations.md`](./data-operations.md).
|
|
5
|
+
> For Tree Grid / Hierarchical Grid / Pivot Grid / Grid Lite setup — see [`types.md`](./types.md).
|
|
6
|
+
> For paging and remote data — see [`paging-remote.md`](./paging-remote.md).
|
|
7
|
+
|
|
8
|
+
## Contents
|
|
9
|
+
|
|
10
|
+
- [State Persistence](#state-persistence)
|
|
11
|
+
- [Tree Grid Data Operations](#tree-grid-data-operations)
|
|
12
|
+
- [Hierarchical Grid Data Operations](#hierarchical-grid-data-operations)
|
|
13
|
+
- [Pivot Grid Data Operations](#pivot-grid-data-operations)
|
|
14
|
+
- [Grid Lite Data Operations](#grid-lite-data-operations)
|
|
15
|
+
- [Key Rules](#key-rules)
|
|
16
|
+
|
|
17
|
+
## State Persistence
|
|
18
|
+
|
|
19
|
+
> **Docs:** [State Persistence](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/state-persistence) (substitute URL prefix per grid type)
|
|
20
|
+
|
|
21
|
+
### Saving and Restoring Grid State
|
|
22
|
+
|
|
23
|
+
Use `IgxGridStateDirective` to persist sorting, filtering, grouping, paging, selection, and column state:
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<igx-grid #grid [data]="data()" igxGridState>
|
|
27
|
+
<igx-column field="name" [sortable]="true" [filterable]="true" [groupable]="true"></igx-column>
|
|
28
|
+
</igx-grid>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { IgxGridStateDirective } from 'igniteui-angular/grids/core';
|
|
33
|
+
|
|
34
|
+
export class StatefulGridComponent {
|
|
35
|
+
gridState = viewChild.required(IgxGridStateDirective);
|
|
36
|
+
|
|
37
|
+
saveState() {
|
|
38
|
+
const state = this.gridState().getState();
|
|
39
|
+
localStorage.setItem('gridState', state);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
restoreState() {
|
|
43
|
+
const state = localStorage.getItem('gridState');
|
|
44
|
+
if (state) {
|
|
45
|
+
this.gridState().setState(state);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Selective State Features
|
|
52
|
+
|
|
53
|
+
Control which features are persisted:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<igx-grid #grid [data]="data()" [igxGridState]="stateOptions">
|
|
57
|
+
</igx-grid>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
stateOptions = {
|
|
62
|
+
sorting: true,
|
|
63
|
+
filtering: true,
|
|
64
|
+
groupBy: true,
|
|
65
|
+
paging: true,
|
|
66
|
+
columns: true,
|
|
67
|
+
cellSelection: false, // skip selection state
|
|
68
|
+
rowSelection: false,
|
|
69
|
+
columnSelection: false,
|
|
70
|
+
advancedFiltering: true,
|
|
71
|
+
rowPinning: true,
|
|
72
|
+
expansion: true
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Restoring Custom Strategies
|
|
77
|
+
|
|
78
|
+
`IgxGridState` does **not** persist functions — this includes sorting strategies, filtering strategies, column formatters, summaries, `cellClasses`, and `cellStyles`. Use the `stateParsed` event to reapply these after restoring state:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
restoreState() {
|
|
82
|
+
const stateJson = localStorage.getItem('gridState');
|
|
83
|
+
if (!stateJson) return;
|
|
84
|
+
|
|
85
|
+
// Subscribe to stateParsed to reapply custom strategies before state is applied
|
|
86
|
+
this.gridState().stateParsed.pipe(take(1)).subscribe(parsedState => {
|
|
87
|
+
parsedState.sorting?.forEach(expr => expr.strategy = NoopSortingStrategy.instance());
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
this.gridState().setState(stateJson);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Restoring Column Templates
|
|
95
|
+
|
|
96
|
+
Column templates are also not serialized. Use the `columnInit` event to reassign them:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
@ViewChild('activeTemplate', { static: true }) public activeTemplate: TemplateRef<any>;
|
|
100
|
+
|
|
101
|
+
onColumnInit(column: IgxColumnComponent) {
|
|
102
|
+
if (column.field === 'IsActive') {
|
|
103
|
+
column.bodyTemplate = this.activeTemplate;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<igx-grid #grid [data]="data()" igxGridState (columnInit)="onColumnInit($event)">
|
|
110
|
+
<ng-template #activeTemplate igxCell let-val="val">
|
|
111
|
+
<igx-checkbox [checked]="val"></igx-checkbox>
|
|
112
|
+
</ng-template>
|
|
113
|
+
</igx-grid>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Tree Grid Data Operations
|
|
117
|
+
|
|
118
|
+
> **Docs:** [Tree Grid](https://www.infragistics.com/products/ignite-ui-angular/angular/components/treegrid/tree-grid) · [Load on Demand](https://www.infragistics.com/products/ignite-ui-angular/angular/components/treegrid/load-on-demand)
|
|
119
|
+
|
|
120
|
+
### Recursive Filtering Behavior
|
|
121
|
+
|
|
122
|
+
Tree Grid filtering is **inclusive** — when a child matches, all its ancestors are kept visible (marked as `isFilteredOutParent`) and auto-expanded. This is the default `TreeGridFilteringStrategy`.
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<igx-tree-grid #treeGrid
|
|
126
|
+
[data]="employees()"
|
|
127
|
+
[primaryKey]="'id'"
|
|
128
|
+
[foreignKey]="'managerId'"
|
|
129
|
+
[allowFiltering]="true"
|
|
130
|
+
[filterMode]="'excelStyleFilter'"
|
|
131
|
+
height="600px">
|
|
132
|
+
<igx-column field="name" [filterable]="true" [sortable]="true"></igx-column>
|
|
133
|
+
<igx-column field="title" [filterable]="true"></igx-column>
|
|
134
|
+
</igx-tree-grid>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
When you filter for `title = 'Developer'`, all ancestor rows are shown even though they don't match, and they're auto-expanded so you can see the matching children in context.
|
|
138
|
+
|
|
139
|
+
### Per-Level Sorting
|
|
140
|
+
|
|
141
|
+
Tree Grid sorting is applied **within each parent level** — children are sorted among siblings, not globally flattened:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// This sorts employees within their respective manager, not globally
|
|
145
|
+
this.treeGridRef().sort({ fieldName: 'name', dir: SortingDirection.Asc, ignoreCase: true });
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Tree Grid Batch Editing
|
|
149
|
+
|
|
150
|
+
Tree Grid uses `HierarchicalTransactionService` — each transaction carries a `path` array tracing the parent hierarchy, enabling proper undo/redo of nested changes:
|
|
151
|
+
|
|
152
|
+
```html
|
|
153
|
+
<igx-tree-grid #treeGrid
|
|
154
|
+
[data]="employees()"
|
|
155
|
+
[primaryKey]="'id'"
|
|
156
|
+
[foreignKey]="'managerId'"
|
|
157
|
+
[batchEditing]="true"
|
|
158
|
+
[rowEditable]="true"
|
|
159
|
+
height="600px">
|
|
160
|
+
<igx-column field="name" [editable]="true"></igx-column>
|
|
161
|
+
</igx-tree-grid>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// Add a row as child of a specific parent
|
|
166
|
+
this.treeGridRef().addRow({ id: 100, name: 'New Employee', managerId: 2 }, 2);
|
|
167
|
+
|
|
168
|
+
// Cascade delete — deleting a parent removes all descendants (default behavior)
|
|
169
|
+
this.treeGridRef().deleteRow(2); // deletes row 2 and all its children
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Hierarchical Grid Data Operations
|
|
173
|
+
|
|
174
|
+
> **Docs:** [Hierarchical Grid](https://www.infragistics.com/products/ignite-ui-angular/angular/components/hierarchicalgrid/hierarchical-grid) · [Load on Demand](https://www.infragistics.com/products/ignite-ui-angular/angular/components/hierarchicalgrid/load-on-demand)
|
|
175
|
+
|
|
176
|
+
### Independent Grid Levels
|
|
177
|
+
|
|
178
|
+
Each level of a hierarchical grid has its **own independent** sorting, filtering, and paging state. Configure features on the `<igx-row-island>` blueprint:
|
|
179
|
+
|
|
180
|
+
```html
|
|
181
|
+
<igx-hierarchical-grid #hGrid
|
|
182
|
+
[data]="companies()"
|
|
183
|
+
[primaryKey]="'id'"
|
|
184
|
+
[allowFiltering]="true"
|
|
185
|
+
[filterMode]="'excelStyleFilter'"
|
|
186
|
+
height="600px">
|
|
187
|
+
|
|
188
|
+
<igx-column field="name" [sortable]="true" [filterable]="true"></igx-column>
|
|
189
|
+
|
|
190
|
+
<!-- Each row island defines column/feature config for that level -->
|
|
191
|
+
<igx-row-island [key]="'orders'" [primaryKey]="'orderId'" [allowFiltering]="true" [rowEditable]="true">
|
|
192
|
+
<igx-column field="orderId" [sortable]="true" [filterable]="true"></igx-column>
|
|
193
|
+
<igx-column field="amount" dataType="number" [editable]="true"></igx-column>
|
|
194
|
+
|
|
195
|
+
<igx-paginator [perPage]="10"></igx-paginator>
|
|
196
|
+
</igx-row-island>
|
|
197
|
+
</igx-hierarchical-grid>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Accessing Child Grid Instances
|
|
201
|
+
|
|
202
|
+
To perform programmatic operations on child grids, use the `(gridCreated)` event:
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
onChildGridCreated(event: IGridCreatedEventArgs) {
|
|
206
|
+
const childGrid = event.grid;
|
|
207
|
+
// Example: apply a default sort to all child grids
|
|
208
|
+
childGrid.sort({ fieldName: 'orderId', dir: SortingDirection.Desc, ignoreCase: false });
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
```html
|
|
213
|
+
<igx-row-island [key]="'orders'" (gridCreated)="onChildGridCreated($event)">
|
|
214
|
+
<igx-column field="orderId" [sortable]="true"></igx-column>
|
|
215
|
+
</igx-row-island>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Batch Editing Propagation
|
|
219
|
+
|
|
220
|
+
Setting `[batchEditing]="true"` on the root hierarchical grid automatically propagates to all child grids:
|
|
221
|
+
|
|
222
|
+
```html
|
|
223
|
+
<igx-hierarchical-grid #hGrid
|
|
224
|
+
[data]="companies()"
|
|
225
|
+
[primaryKey]="'id'"
|
|
226
|
+
[batchEditing]="true"
|
|
227
|
+
[rowEditable]="true">
|
|
228
|
+
<!-- All child grids inherit batchEditing automatically -->
|
|
229
|
+
<igx-row-island [key]="'departments'" [primaryKey]="'deptId'" [rowEditable]="true">
|
|
230
|
+
<igx-column field="name" [editable]="true"></igx-column>
|
|
231
|
+
</igx-row-island>
|
|
232
|
+
</igx-hierarchical-grid>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
> **NOTE**: Each child grid instance has its **own** `TransactionService`. Commits must be done per grid instance.
|
|
236
|
+
|
|
237
|
+
## Pivot Grid Data Operations
|
|
238
|
+
|
|
239
|
+
> **Docs:** [Pivot Grid](https://www.infragistics.com/products/ignite-ui-angular/angular/components/pivotGrid/pivot-grid)
|
|
240
|
+
|
|
241
|
+
> **IMPORTANT**: The Pivot Grid does NOT use standard sorting, filtering, editing, or paging APIs. All data operations are controlled through `pivotConfiguration`.
|
|
242
|
+
|
|
243
|
+
### Dimension-Based Filtering
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import { FilteringExpressionsTree, FilteringLogic, IgxStringFilteringOperand } from 'igniteui-angular/core';
|
|
247
|
+
|
|
248
|
+
// Create a filter for a dimension
|
|
249
|
+
const regionFilter = new FilteringExpressionsTree(FilteringLogic.Or);
|
|
250
|
+
regionFilter.filteringOperands = [
|
|
251
|
+
{
|
|
252
|
+
fieldName: 'Region',
|
|
253
|
+
condition: IgxStringFilteringOperand.instance().condition('equals'),
|
|
254
|
+
searchVal: 'North America'
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
fieldName: 'Region',
|
|
258
|
+
condition: IgxStringFilteringOperand.instance().condition('equals'),
|
|
259
|
+
searchVal: 'Europe'
|
|
260
|
+
}
|
|
261
|
+
];
|
|
262
|
+
|
|
263
|
+
// Apply the filter to a dimension
|
|
264
|
+
this.pivotConfig.filters[0].filter = regionFilter;
|
|
265
|
+
// Notify the grid of the change
|
|
266
|
+
this.pivotGridRef().pipeTrigger++;
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Dimension-Based Sorting
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
// Sort a row dimension
|
|
273
|
+
this.pivotConfig.rows[0].sortDirection = SortingDirection.Desc;
|
|
274
|
+
this.pivotGridRef().pipeTrigger++;
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Key Pivot Grid Limitations
|
|
278
|
+
|
|
279
|
+
- No cell/row editing, batch editing, or row adding
|
|
280
|
+
- No paging
|
|
281
|
+
- No column pinning, moving, or hiding (columns are auto-generated)
|
|
282
|
+
- No row dragging
|
|
283
|
+
- No standard filtering (`allowFiltering` is forced to `false`)
|
|
284
|
+
- No GroupBy (grouping is inherent via dimensions)
|
|
285
|
+
- State persistence serializes the full `pivotConfiguration`
|
|
286
|
+
|
|
287
|
+
## Grid Lite Data Operations
|
|
288
|
+
|
|
289
|
+
> **Grid Lite sorting, filtering, remote data, events, and limitations are fully documented in [`types.md`](./types.md#grid-lite).** Refer to that file for all Grid Lite data operations — this section intentionally avoids duplicating that content.
|
|
290
|
+
>
|
|
291
|
+
> Key differences from Flat/Tree/Hierarchical Grid APIs:
|
|
292
|
+
> - Uses `IgxGridLiteSortingExpression` / `IgxGridLiteFilteringExpression` (NOT `ISortingExpression` / `FilteringExpressionsTree`)
|
|
293
|
+
> - Uses `dataPipelineConfiguration` for remote ops (NOT noop strategies + events)
|
|
294
|
+
> - Has no editing, grouping, paging, summaries, selection, state persistence, or export
|
|
295
|
+
|
|
296
|
+
## Key Rules
|
|
297
|
+
|
|
298
|
+
1. **State persistence** — use `IgxGridStateDirective` to save/restore sort, filter, group, and column configuration; functions (formatters, strategies, summaries) must be reapplied via `stateParsed` event
|
|
299
|
+
2. **Tree Grid filtering is recursive** — parents of matching children are always shown and auto-expanded
|
|
300
|
+
3. **Hierarchical Grid levels are independent** — sorting/filtering/paging don't cascade; configure on `<igx-row-island>`
|
|
301
|
+
4. **Pivot Grid is read-only** — no editing, paging, or standard filtering/sorting; use `pivotConfiguration` for all data operations
|
|
302
|
+
5. **Grid Lite has its own API** — uses `IgxGridLiteSortingExpression`/`IgxGridLiteFilteringExpression` (NOT `ISortingExpression`/`FilteringExpressionsTree`), `dataPipelineConfiguration` for remote ops (NOT noop strategies), and has no editing, grouping, paging, summaries, or selection
|
|
303
|
+
6. **Use the correct component type for `viewChild`** — `IgxGridLiteComponent`, `IgxGridComponent`, `IgxTreeGridComponent`, `IgxHierarchicalGridComponent`, or `IgxPivotGridComponent`
|
|
304
|
+
7. **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`)
|
|
305
|
+
8. **Use signals for data** — `[data]="myData()"` with `signal<T[]>([])`
|
|
306
|
+
|
|
307
|
+
## See Also
|
|
308
|
+
|
|
309
|
+
- [`data-operations.md`](./data-operations.md) — Sorting, filtering, grouping, and canonical grid import patterns
|
|
310
|
+
- [`paging-remote.md`](./paging-remote.md) — Paging, remote data operations, virtualization
|
|
311
|
+
- [`editing.md`](./editing.md) — Cell editing, row editing, batch editing, validation, summaries
|
|
312
|
+
- [`structure.md`](./structure.md) — Grid structure, column configuration, templates, layout, selection
|
|
313
|
+
- [`../../igniteui-angular-components/SKILL.md`](../../igniteui-angular-components/SKILL.md) — Non-grid Ignite UI components
|
|
314
|
+
- [`../../igniteui-angular-theming/SKILL.md`](../../igniteui-angular-theming/SKILL.md) — Theming & Styling
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Grid Structure — Column Configuration, Sorting, Filtering & Selection
|
|
2
|
+
|
|
3
|
+
> **Part of the [`igniteui-angular-grids`](../SKILL.md) skill hub.**
|
|
4
|
+
> For grid type selection, imports, and feature availability — see the hub.
|
|
5
|
+
> For editing, grouping, summaries, toolbar, export — see [`features.md`](./features.md).
|
|
6
|
+
> For Tree Grid, Hierarchical Grid, Grid Lite, Pivot Grid specifics — see [`types.md`](./types.md).
|
|
7
|
+
> For programmatic data operations — see [`data-operations.md`](./data-operations.md).
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- [Quick Start](#quick-start)
|
|
12
|
+
- [Column Configuration](#column-configuration)
|
|
13
|
+
- [Sorting](#sorting)
|
|
14
|
+
- [Filtering](#filtering)
|
|
15
|
+
- [Selection](#selection)
|
|
16
|
+
- [Key Rules](#key-rules)
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
### Imports
|
|
21
|
+
|
|
22
|
+
> **AGENT INSTRUCTION:** Check `package.json` to determine whether the project uses `igniteui-angular` or `@infragistics/igniteui-angular`. Always import from the specific entry point of whichever package is installed. Never import from the root barrel of either package.
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Open-source package — import from specific entry points
|
|
26
|
+
import { IgxGridComponent, IGX_GRID_DIRECTIVES } from 'igniteui-angular/grids/grid';
|
|
27
|
+
|
|
28
|
+
// Licensed package — same entry-point structure, different prefix
|
|
29
|
+
// import { IgxGridComponent, IGX_GRID_DIRECTIVES } from '@infragistics/igniteui-angular/grids/grid';
|
|
30
|
+
|
|
31
|
+
// AVOID — never import from the root barrel (wrong for BOTH variants)
|
|
32
|
+
// import { IgxGridComponent } from 'igniteui-angular';
|
|
33
|
+
// import { IgxGridComponent } from '@infragistics/igniteui-angular';
|
|
34
|
+
|
|
35
|
+
import { Component, ChangeDetectionStrategy, signal, viewChild } from '@angular/core';
|
|
36
|
+
|
|
37
|
+
@Component({
|
|
38
|
+
selector: 'app-users-grid',
|
|
39
|
+
imports: [IGX_GRID_DIRECTIVES],
|
|
40
|
+
templateUrl: './users-grid.component.html',
|
|
41
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
42
|
+
})
|
|
43
|
+
export class UsersGridComponent {
|
|
44
|
+
// Signal-based view child — use #grid on the template element
|
|
45
|
+
gridRef = viewChild.required<IgxGridComponent>('grid');
|
|
46
|
+
|
|
47
|
+
protected users = signal<User[]>([]);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Basic Grid
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<igx-grid #grid
|
|
55
|
+
[data]="users()"
|
|
56
|
+
[primaryKey]="'id'"
|
|
57
|
+
[autoGenerate]="false"
|
|
58
|
+
height="600px"
|
|
59
|
+
width="100%">
|
|
60
|
+
|
|
61
|
+
<igx-column field="id" header="ID" [hidden]="true"></igx-column>
|
|
62
|
+
<igx-column field="name" header="Name" [sortable]="true" [filterable]="true" [resizable]="true"></igx-column>
|
|
63
|
+
<igx-column field="email" header="Email" [sortable]="true" [filterable]="true"></igx-column>
|
|
64
|
+
<igx-column field="role" header="Role" [groupable]="true" [filterable]="true"></igx-column>
|
|
65
|
+
<igx-column field="salary" header="Salary" dataType="number" [hasSummary]="true"></igx-column>
|
|
66
|
+
<igx-column field="hireDate" header="Hire Date" dataType="date" [sortable]="true"></igx-column>
|
|
67
|
+
<igx-column field="active" header="Active" dataType="boolean"></igx-column>
|
|
68
|
+
|
|
69
|
+
</igx-grid>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Column Configuration
|
|
73
|
+
|
|
74
|
+
> **Docs:** [Column Types](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/column-types)
|
|
75
|
+
|
|
76
|
+
### Data Types
|
|
77
|
+
|
|
78
|
+
Set `dataType` to enable proper formatting, filtering, sorting, and editing:
|
|
79
|
+
|
|
80
|
+
| dataType | Behavior |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `string` | Text input, string filtering |
|
|
83
|
+
| `number` | Numeric input, number filtering, number summaries |
|
|
84
|
+
| `boolean` | Checkbox editor, boolean filtering |
|
|
85
|
+
| `date` | Date picker editor, date filtering |
|
|
86
|
+
| `dateTime` | Date+time editor |
|
|
87
|
+
| `time` | Time picker editor |
|
|
88
|
+
| `currency` | Currency formatting, number filtering |
|
|
89
|
+
| `percent` | Percentage formatting |
|
|
90
|
+
| `image` | Image rendering (read-only) |
|
|
91
|
+
|
|
92
|
+
### Column Templates
|
|
93
|
+
|
|
94
|
+
> **Docs:** [Column Configuration](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/grid#angular-grid-column-configuration)
|
|
95
|
+
|
|
96
|
+
Override default rendering with template directives:
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<igx-column field="status" header="Status">
|
|
100
|
+
<!-- Custom cell template -->
|
|
101
|
+
<ng-template igxCell let-cell="cell">
|
|
102
|
+
<igx-badge [type]="cell.value === 'Active' ? 'success' : 'error'">
|
|
103
|
+
{{ cell.value }}
|
|
104
|
+
</igx-badge>
|
|
105
|
+
</ng-template>
|
|
106
|
+
|
|
107
|
+
<!-- Custom header template -->
|
|
108
|
+
<ng-template igxHeader let-column>
|
|
109
|
+
<igx-icon>verified</igx-icon> {{ column.header }}
|
|
110
|
+
</ng-template>
|
|
111
|
+
|
|
112
|
+
<!-- Custom editor template -->
|
|
113
|
+
<ng-template igxCellEditor let-cell="cell">
|
|
114
|
+
<igx-select [(ngModel)]="cell.editValue">
|
|
115
|
+
<igx-select-item value="Active">Active</igx-select-item>
|
|
116
|
+
<igx-select-item value="Inactive">Inactive</igx-select-item>
|
|
117
|
+
</igx-select>
|
|
118
|
+
</ng-template>
|
|
119
|
+
|
|
120
|
+
<!-- Custom filter cell template -->
|
|
121
|
+
<ng-template igxFilterCellTemplate let-column="column">
|
|
122
|
+
<input (input)="onCustomFilter($event, column)" />
|
|
123
|
+
</ng-template>
|
|
124
|
+
|
|
125
|
+
<!-- Custom summary template -->
|
|
126
|
+
<ng-template igxSummary let-summaryResults>
|
|
127
|
+
Active: {{ getActiveCount(summaryResults) }}
|
|
128
|
+
</ng-template>
|
|
129
|
+
</igx-column>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Column Groups
|
|
133
|
+
|
|
134
|
+
> **Docs:** [Collapsible Column Groups](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/collapsible-column-groups)
|
|
135
|
+
|
|
136
|
+
Group columns under a shared header:
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<igx-column-group header="Personal Info">
|
|
140
|
+
<igx-column field="firstName" header="First Name"></igx-column>
|
|
141
|
+
<igx-column field="lastName" header="Last Name"></igx-column>
|
|
142
|
+
</igx-column-group>
|
|
143
|
+
|
|
144
|
+
<igx-column-group header="Contact">
|
|
145
|
+
<igx-column field="email" header="Email"></igx-column>
|
|
146
|
+
<igx-column field="phone" header="Phone"></igx-column>
|
|
147
|
+
</igx-column-group>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Multi-Row Layout (MRL)
|
|
151
|
+
|
|
152
|
+
> **Docs:** [Multi-Row Layout](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/multi-row-layout)
|
|
153
|
+
|
|
154
|
+
Create complex cell layouts spanning multiple rows/columns:
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<igx-column-layout>
|
|
158
|
+
<igx-column field="name" [rowStart]="1" [colStart]="1" [colEnd]="3"></igx-column>
|
|
159
|
+
<igx-column field="email" [rowStart]="2" [colStart]="1"></igx-column>
|
|
160
|
+
<igx-column field="phone" [rowStart]="2" [colStart]="2"></igx-column>
|
|
161
|
+
</igx-column-layout>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Column Pinning
|
|
165
|
+
|
|
166
|
+
> **Docs:** [Column Pinning](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/column-pinning)
|
|
167
|
+
|
|
168
|
+
```html
|
|
169
|
+
<igx-column field="name" [pinned]="true"></igx-column>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Or programmatically: `this.gridRef().pinColumn('name')`.
|
|
173
|
+
|
|
174
|
+
## Sorting
|
|
175
|
+
|
|
176
|
+
> **Docs:** [Sorting](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/sorting) (substitute URL prefix per grid type — see hub instruction)
|
|
177
|
+
|
|
178
|
+
```html
|
|
179
|
+
<igx-grid
|
|
180
|
+
[data]="data()"
|
|
181
|
+
[(sortingExpressions)]="sortExprs"
|
|
182
|
+
[sortingOptions]="{ mode: 'multiple' }">
|
|
183
|
+
<igx-column field="name" [sortable]="true"></igx-column>
|
|
184
|
+
</igx-grid>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Programmatic sorting:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
this.gridRef().sort({ fieldName: 'name', dir: SortingDirection.Asc, ignoreCase: true });
|
|
191
|
+
this.gridRef().clearSort();
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Events: `(sorting)` (cancelable), `(sortingDone)`.
|
|
195
|
+
|
|
196
|
+
For advanced programmatic sorting patterns, custom sort strategies, and sorting events — see [`data-operations.md`](./data-operations.md).
|
|
197
|
+
|
|
198
|
+
## Filtering
|
|
199
|
+
|
|
200
|
+
### Quick Filter (Row Filter)
|
|
201
|
+
|
|
202
|
+
> **Docs:** [Filtering](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/filtering)
|
|
203
|
+
|
|
204
|
+
```html
|
|
205
|
+
<igx-grid [allowFiltering]="true" [filterMode]="'quickFilter'">
|
|
206
|
+
<igx-column field="name" [filterable]="true"></igx-column>
|
|
207
|
+
</igx-grid>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Excel-Style Filter
|
|
211
|
+
|
|
212
|
+
> **Docs:** [Excel-Style Filtering](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/excel-style-filtering)
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
<igx-grid [allowFiltering]="true" [filterMode]="'excelStyleFilter'">
|
|
216
|
+
<igx-column field="name" [filterable]="true"></igx-column>
|
|
217
|
+
</igx-grid>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Advanced Filtering Dialog
|
|
221
|
+
|
|
222
|
+
> **Docs:** [Advanced Filtering](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/advanced-filtering)
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<igx-grid [allowAdvancedFiltering]="true">
|
|
226
|
+
<!-- Advanced filtering UI is shown via toolbar or API -->
|
|
227
|
+
</igx-grid>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Programmatic Filtering
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
this.gridRef().filter('name', 'John', IgxStringFilteringOperand.instance().condition('contains'), true);
|
|
234
|
+
this.gridRef().clearFilter('name');
|
|
235
|
+
this.gridRef().clearFilter(); // clear all
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Events: `(filtering)` (cancelable), `(filteringDone)`.
|
|
239
|
+
|
|
240
|
+
For advanced programmatic filtering, complex AND/OR trees, and remote filtering patterns — see [`data-operations.md`](./data-operations.md).
|
|
241
|
+
|
|
242
|
+
## Selection
|
|
243
|
+
|
|
244
|
+
### Row Selection
|
|
245
|
+
|
|
246
|
+
> **Docs:** [Row Selection](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/row-selection)
|
|
247
|
+
|
|
248
|
+
```html
|
|
249
|
+
<igx-grid [rowSelection]="'multiple'" [primaryKey]="'id'" [(selectedRows)]="selectedIds">
|
|
250
|
+
<!-- Optional: Custom row selector checkbox -->
|
|
251
|
+
<ng-template igxRowSelector let-rowContext>
|
|
252
|
+
<igx-checkbox [checked]="rowContext.selected" (change)="rowContext.select(!rowContext.selected)">
|
|
253
|
+
</igx-checkbox>
|
|
254
|
+
</ng-template>
|
|
255
|
+
</igx-grid>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Modes: `'none'`, `'single'`, `'multiple'`, `'multipleCascade'` (tree grids).
|
|
259
|
+
|
|
260
|
+
### Cell Selection
|
|
261
|
+
|
|
262
|
+
> **Docs:** [Cell Selection](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/cell-selection)
|
|
263
|
+
|
|
264
|
+
```html
|
|
265
|
+
<igx-grid [cellSelection]="'multiple'"></igx-grid>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Column Selection
|
|
269
|
+
|
|
270
|
+
> **Docs:** [Column Selection](https://www.infragistics.com/products/ignite-ui-angular/angular/components/grid/column-selection)
|
|
271
|
+
|
|
272
|
+
```html
|
|
273
|
+
<igx-grid [columnSelection]="'multiple'">
|
|
274
|
+
<igx-column field="name" [selectable]="true"></igx-column>
|
|
275
|
+
</igx-grid>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Events: `(rowSelectionChanging)`, `(columnSelectionChanging)`, `(selected)` (cell).
|
|
279
|
+
|
|
280
|
+
## Key Rules
|
|
281
|
+
|
|
282
|
+
1. **Pick the right grid type first** — see the [hub](../SKILL.md) for the decision guide
|
|
283
|
+
2. **Always set `[primaryKey]`** — required for editing, selection, row operations (Flat, Tree, Hierarchical, Pivot grids; NOT Grid Lite)
|
|
284
|
+
3. **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
|
|
285
|
+
4. **Use the right component type for `viewChild`** — `IgxGridLiteComponent`, `IgxGridComponent`, `IgxTreeGridComponent`, `IgxHierarchicalGridComponent`, or `IgxPivotGridComponent`
|
|
286
|
+
5. **Set `[autoGenerate]="false"`** and define columns explicitly for production grids (except Pivot Grid where columns are auto-generated)
|
|
287
|
+
6. **Set `dataType` on every column** for correct filtering, sorting, editing, and summaries
|
|
288
|
+
7. **Use signals** for data binding — `[data]="myData()"` with `signal<T[]>([])`
|
|
289
|
+
8. **Virtualization is automatic** — don't wrap grids in virtual scroll containers
|
|
290
|
+
|
|
291
|
+
## See Also
|
|
292
|
+
|
|
293
|
+
- [`features.md`](./features.md) — Editing, grouping, summaries, toolbar, export, row drag, action strip, master-detail
|
|
294
|
+
- [`types.md`](./types.md) — Tree Grid, Hierarchical Grid, Grid Lite, Pivot Grid specifics
|
|
295
|
+
- [`data-operations.md`](./data-operations.md) — Programmatic sorting, filtering, grouping, canonical import patterns
|
|
296
|
+
- [`paging-remote.md`](./paging-remote.md) — Paging, remote data operations, virtualization
|
|
297
|
+
- [`editing.md`](./editing.md) — Cell editing, row editing, batch editing, validation, summaries
|
|
298
|
+
- [`state.md`](./state.md) — State persistence, grid-type-specific operations
|
|
299
|
+
- [`../../igniteui-angular-theming/SKILL.md`](../../igniteui-angular-theming/SKILL.md) — Grid styling and theming
|