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
* You should define only aggregates that you will use to avoid unnecessary calculations that may be noticeable on large data sets.
@@ -162,11 +160,22 @@ Enable and use aggregates. To see the full effect, group by a column - "Team" an
162
160
163
161
* If you update a field of a model the `Data` collection in the view-model, aggregates will not be updated automatically - the grid needs to re-evaluate that data first, and since this is an expensive operation a UI render does not trigger it. You can [update the data collection]({%slug grid-refresh-data%}) yourself, or fetching it anew from the service (example [here]({%slug components/grid/editing/overview%}), see how the Create/Update/Delete events fetch data anew).
164
162
165
-
* If you use [`OnRead`]({%slug components/grid/manual-operations%}), the Grid will calculate aggregates from the data on the current page only. It is still possible to [calculate and display aggregates, which are based on all the data]({%slug grid-templates-column-footer%}#notes).
163
+
* If you [bind the Grid via `OnRead` event]({%slug components/grid/manual-operations%}), make sure to set `AggregateResults` in the `GridReadEventArgs` event argument object. Otherwise the Grid will calculate aggregates from the data on the current page only.
Copy file name to clipboardExpand all lines: components/grid/manual-operations.md
+29-20Lines changed: 29 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,23 +10,12 @@ position: 55
10
10
11
11
# Manual Data Source Operations
12
12
13
-
By default, the grid will receive the entire collection of data, and it will perform the necessary operations (like [paging]({%slug components/grid/features/paging%}), [sorting]({%slug components/grid/features/sorting%}), [filtering]({%slug components/grid/filtering%})) internally to it. You can perform these operations yourself by handling the `OnRead` event of the grid as shown in the example below. The data source will be read after each [CUD operation]({%slug components/grid/editing/overview%}) as well, to ensure fresh data.
13
+
By default, the Grid will receive the entire collection of data, and it will perform the necessary operations (like [paging]({%slug components/grid/features/paging%}), [sorting]({%slug components/grid/features/sorting%}), [filtering]({%slug components/grid/filtering%})) internally.
14
14
15
-
>tip This article describes how you can load data on demand and implement filtering, paging, sorting on the server.
16
-
>
17
-
> Detailed examples showcase the functionality of the [`OnRead` event]({%slug common-features-data-binding-onread%}) that you need to use.
18
-
>
19
-
> You can also find runnable sample apps in the [Serialize the DataSoureRequest to the server](https://github.com/telerik/blazor-ui/tree/master/grid/datasourcerequest-on-server) repo.
20
-
21
-
The parameter of type `DataSourceRequest` exposes information about the desired paging, filtering and sorting so you can, for example, call your remote endpoint with appropriate parameters so its performance is optimized and it fetches only the relevant data.
15
+
You can perform all data operations yourself (e.g. on the server) and load data on demand by using the `OnRead` event of the Grid. The data source will be read after each [CUD operation]({%slug components/grid/editing/overview%}) as well, to ensure fresh data.
22
16
23
-
When the `OnRead` event is used, the internal operations are disabled and you must perform them all in the `OnRead` event. You must set:
17
+
>tip Make sure to get familiar with all the general [`OnRead` event documentation]({%slug common-features-data-binding-onread%}) first.
24
18
25
-
* the data to `args.Data`
26
-
* the total number of items (if there is no paging) to `args.Total`
27
-
* the Grid itself should set the `TItem` attribute to the model type
28
-
29
-
The event arguments of `OnRead` will receive the `Page` that comes from the application. For example, if you load the grid [state]({%slug grid-state%}), or you set the parameter value yourself, that value will be passed to the event handler. If it is out of the range of the available data, it will be up to the application to handle that discrepancy.
30
19
31
20
## Examples
32
21
@@ -39,6 +28,7 @@ Examples:
39
28
*[Custom paging with a remote service](#custom-paging-with-a-remote-service)
@@ -298,6 +289,24 @@ This sample shows how to set up the grid to use grouping with manual data source
298
289
> Thus, clicking the built-in Add command button on its toolbar when there is no data will produce a `null` item and if you have editor templates, there may be null reference errors (the `context` will be `null`). To avoid that, you can [initiate insertion of items through the grid state]({%slug grid-state%}#initiate-editing-or-inserting-of-an-item) in order to ensure a model reference exists.
299
290
300
291
292
+
## Aggregates with OnRead
293
+
294
+
When using [aggregates]({%slug grid-aggregates%}) with `OnRead`, the Grid expects you to set one more property of the `GridReadEventArgs` object - `AggregateResults`. Otherwise the component will show aggregate values for the current page only.
0 commit comments