You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/en/components/grids/_shared/state-persistence.md
+29-15Lines changed: 29 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ The {ProductName} State Persistence in {Platform} {ComponentTitle} allows develo
18
18
<!-- end: React, WebComponents -->
19
19
20
20
<!-- Blazor -->
21
-
The {ProductName} State Persistence in {Platform} {ComponentTitle} allows developers to easily save and restore the grid state. When the `GridState` is applied on the {Platform} `{ComponentName}`, it exposes the `GetStateAsString` and `ApplyStateFromString` methods that developers can use to achieve state persistence in any scenario.
21
+
The {ProductName} State Persistence in {Platform} {ComponentTitle} allows developers to easily save and restore the grid state. When the `GridState` is applied on the {Platform} `{ComponentName}`, it exposes the `GetStateAsStringAsync` and `ApplyStateFromStringAsync` methods that developers can use to achieve state persistence in any scenario.
22
22
<!-- end: Blazor -->
23
23
24
24
## Supported Features
@@ -114,11 +114,17 @@ The developer may choose to get only the state for a certain feature/features, b
114
114
The `GetState` method returns the grid state in a `GridStateInfo` object, containing all the state info. Additional steps may be required in order to save it.
115
115
<!-- end: React, WebComponents -->
116
116
117
-
<!--Blazor, React, WebComponents -->
117
+
<!-- React, WebComponents -->
118
118
The `GetStateAsString` returns a serialized JSON string, so developers can just take it and save it on any data storage (database, cloud, browser localStorage, etc).
119
119
120
120
The developer may choose to get only the state for a certain feature/features, by passing in an array with feature names as an argument. Empty array will result to using the default state options.
121
-
<!-- end: Blazor, React, WebComponents -->
121
+
<!-- end: React, WebComponents -->
122
+
123
+
<!-- Blazor -->
124
+
The `GetStateAsStringAsync` returns a serialized JSON string, so developers can just take it and save it on any data storage (database, cloud, browser localStorage, etc).
125
+
126
+
The developer may choose to get only the state for a certain feature/features, by passing in an array with feature names as an argument. Empty array will result to using the default state options.
`ApplyState` - The method accepts a `GridStateInfo` object as argument and will restore the state of each feature found in the object or specified features as second argument.
200
206
<!-- end: React, WebComponents -->
201
207
202
-
<!--Blazor, React, WebComponents -->
208
+
<!-- React, WebComponents -->
203
209
`ApplyStateFromString` - The method accepts a serialized JSON string as argument and will restore the state of each feature found in the JSON string or specified features as second argument.
204
-
<!-- end: Blazor, React, WebComponents -->
210
+
<!-- end: React, WebComponents -->
211
+
212
+
<!-- Blazor -->
213
+
`ApplyStateFromStringAsync` - The method accepts a serialized JSON string as argument and will restore the state of each feature found in the JSON string or specified features as second argument.
gridState.ApplyStateFromString(gridStateString, new string[0]);
229
-
gridState.ApplyStateFromString(sortingFilteringStates, new string[0])
238
+
gridState.ApplyStateFromStringAsync(gridStateString, new string[0]);
239
+
gridState.ApplyStateFromStringAsync(sortingFilteringStates, new string[0])
230
240
```
231
241
232
242
<!-- Angular -->
@@ -238,7 +248,7 @@ The `Options` object implements the `GridStateOptions` interface, i.e. for every
238
248
<!-- end: React, WebComponents -->
239
249
240
250
<!-- Blazor -->
241
-
The `Options` object implements the `GridStateOptions` interface, i.e. for every key, which is the name of a certain feature, there is the boolean value indicating if this feature state will be tracked. `GetStateAsString` methods will not put the state of these features in the returned value and `ApplyStateFromString` methods will not restore state for them.
251
+
The `Options` object implements the `GridStateOptions` interface, i.e. for every key, which is the name of a certain feature, there is the boolean value indicating if this feature state will be tracked. `GetStateAsStringAsync` methods will not put the state of these features in the returned value and `ApplyStateFromStringAsync` methods will not restore state for them.
242
252
<!-- end: Blazor -->
243
253
244
254
<!-- Angular -->
@@ -421,14 +431,14 @@ function restoreGridState() {
421
431
}
422
432
423
433
async void SaveGridState() {
424
-
string state = gridState.getStateAsString(new string[0]);
434
+
string state = gridState.GetStateAsStringAsync(new string[0]);
Then the `GetState` API will return the state for all grids (root grid and child grids) features excluding `Selection` and `Sorting`. If later on the developer wants to restore only the `Filtering` state for all grids, use:
955
965
```razor
956
-
gridState.ApplyStateFromString(gridStateString, new string[] { "filtering", "rowIslands" });
966
+
gridState.ApplyStateFromStringAsync(gridStateString, new string[] { "filtering", "rowIslands" });
*`GetState` method uses JSON.stringify() method to convert the original objects to a JSON string. JSON.stringify() does not support Functions, thats why the `GridState` directive will ignore the columns `Formatter`, `Filters`, `Summaries`, `SortStrategy`, `CellClasses`, `CellStyles`, `HeaderTemplate` and `BodyTemplate` properties.
1102
1112
<!-- end: Angular -->
1103
1113
1104
-
<!--Blazor, React, WebComponents -->
1114
+
<!-- React, WebComponents -->
1105
1115
*`GetStateAsString` method uses JSON.stringify() method to convert the original objects to a JSON string. JSON.stringify() does not support Functions, thats why the `GridState` component will ignore the columns `Formatter`, `Filters`, `Summaries`, `SortStrategy`, `CellClasses`, `CellStyles`, `HeaderTemplate` and `BodyTemplate` properties.
1106
-
<!-- end: Blazor, React, WebComponents -->
1116
+
<!-- end: React, WebComponents -->
1117
+
1118
+
<!-- Blazor -->
1119
+
*`GetStateAsString` method uses JSON.stringify() method to convert the original objects to a JSON string. JSON.stringify() does not support Functions, thats why the `GridState` component will ignore the columns `Formatter`, `Filters`, `Summaries`, `SortStrategy`, `CellClasses`, `CellStyles`, `HeaderTemplate` and `BodyTemplate` properties.
0 commit comments