Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(*): Add notes on new state persistance changes. #5979

Open
wants to merge 2 commits into
base: vnext
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions en/components/grids_templates/state-persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ _canonicalLink: grid/state-persistence
* `Expansion`
* `GroupBy`
* `Columns`
* **NEW**: Multi column headers are now supported out of the box
* Multi column headers
@@if (igxName === 'IgxGrid') {
* Multi-row Layout
Copy link
Contributor

@dkamburov dkamburov Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we don't have MRL for the treegrid. Should be added only for the flat grid

}
* Columns order
* Column properties defined by the [`IColumnState`]({environment:angularApiUrl}/interfaces/icolumnstate.html) interface.
* Columns templates and functions are restored using application level code, see [Restoring Column](state-persistence.md#restoring-columns) section.
Expand All @@ -70,7 +73,7 @@ _canonicalLink: grid/state-persistence
* `Row Pinning`
* `Expansion`
* `Columns`
* **NEW**: Multi column headers are now supported out of the box
* Multi column headers
* Columns order
* Column properties defined by the [`IColumnState`]({environment:angularApiUrl}/interfaces/icolumnstate.html) interface.
* Columns templates and functions are restored using application level code, see [Restoring Column](state-persistence.md#restoring-columns) section.
Expand Down Expand Up @@ -173,7 +176,9 @@ public restoreGridState() {
@@if (igxName !== 'IgxPivotGrid') {
## Restoring columns

[`IgxGridState`]({environment:angularApiUrl}/classes/igxgridstatedirective.html) will not persist columns templates, column formatters, etc. by default (see [`limitations`](state-persistence.md#limitations)). Restoring any of these can be achieved with code on application level. Let's show how to do this for templated columns:
When possible the state directive will reuses the columns that already exists on the grid when restoring the state, instead of creating new column instances. The only scenario where a new instance will be created is when the column (or its children in case of a column groups) have no `field` property so there's no way to uniquely identify the matching column and re-use it.

For such scenarios, the following [`limitations`](state-persistence.md#limitations) are imposed. In that case restoring complex objects can be achieved with code on application level. Let's show how to do this for templated columns:

1. Define a template reference variable (in the example below it is `#activeTemplate`) and assign an event handler for the [`columnInit`]({environment:angularApiUrl}/classes/igxgridcomponent.html#columnInit) event:
@@if (igxName === 'IgxGrid') {
Expand Down