|
| 1 | +--- |
| 2 | +title: Load On Demand |
| 3 | +page_title: .NET MAUI TreeDataGrid Documentation - Load on Demand |
| 4 | +description: Learn more about the available modes and approaches to load huge sets of data in the Telerik UI for .NET MAUI TreeDataGrid to improve the performance of the component and save computing resources. |
| 5 | +position: 13 |
| 6 | +slug: treedatagrid-loadondemand |
| 7 | +--- |
| 8 | + |
| 9 | +# .NET MAUI DataGrid Load On Demand |
| 10 | + |
| 11 | +The [Telerik UI for .NET MAUI TreeDataGrid]({%slug treedatagrid-overview%}) enables you to improve its performance and save computing resources, by loading data in the `RadTreeDataGrid` when the control is already displayed. |
| 12 | + |
| 13 | +To load a large data set on mobile devices, you can use incremental data loading at the time when the user required the items to be visualized. |
| 14 | + |
| 15 | +## Modes |
| 16 | + |
| 17 | +The DataGrid provides the following data-loading modes, which are present in the `LoadOnDemandMode` enumeration: |
| 18 | + |
| 19 | +* `Automatic`—The load-on-demand mechanism is activated when you scroll down near the last item present in the viewport. |
| 20 | + |
| 21 | + >important To control when the items will start loading, set the `LoadOnDemandBufferItemsCount` property. It indicates at which point the additional items will start loading. For example, setting it to `20` will cause the new items to be loaded when you have scrolled the DataGrid, so that only 20 of the originally loaded items are left below. |
| 22 | +
|
| 23 | +* `Manual`—A **Load More** button is present at the bottom of the DataGrid. Clicking it will load additional items based on the approach you have chosen for loading the items (through the event, the command, or the collection). |
| 24 | + |
| 25 | +>tip When the `LoadOnDemandMode` is `Automatic` and grouping applies to the control, the `LoadOnDemandMode` transforms to `Manual`. |
| 26 | +
|
| 27 | +## Approaches |
| 28 | + |
| 29 | +The DataGrid supports the following options for using its load-on-demand feature, depending on your application requirements: |
| 30 | + |
| 31 | + * [Using the `LoadOnDemand` collection](#loadondemand-collection) |
| 32 | + * [Using the `LoadOnDemand` event](#loadondemand-event) |
| 33 | + * [Using the `LoadMoreData` command](#loadmoredata-command) |
| 34 | + |
| 35 | +### LoadOnDemand Collection |
| 36 | + |
| 37 | +To use this approach, you have to feed the `RadDataGrid` with a collection of type `LoadOnDemandCollection`. `LoadOnDemandCollection` is a generic type, so you need to point the type of objects it will contain. The type extends the `ObservableCollection<T>` class and expects a `Func<CancellationToken, IEnumerable>` in the constructor. |
| 38 | + |
| 39 | +### LoadOnDemand Event |
| 40 | + |
| 41 | +You can load new items by utilizing the `LoadOnDemand` event. The event uses `LoadOnDemandEventArgs` arguments through which you need to indicate when the data is loaded by setting the `IsDataLoaded`(`bool`) property. |
| 42 | + |
| 43 | +### LoadMoreData Command |
| 44 | + |
| 45 | +The `LoadMoreData` command is another alternative which you can use and which is suitable for MVVM scenarios. |
| 46 | + |
| 47 | +>important Invoking the `ShowLoadOnDemandLoadingIndicator` and `HideLoadOnDemandLoadingIndicators` is a notable part as without calling these methods, the `BusyIndicator` used for the functionality will not be visualized. |
| 48 | +
|
| 49 | +## Styling |
| 50 | + |
| 51 | +Besides the different approaches for loading the data, the DataGrid exposes several mechanisms related to the styling of the functionality which you can use according to the approach you have chosen. |
| 52 | + |
| 53 | +### Load-More-Button Row |
| 54 | + |
| 55 | +The `LoadOnDemandRowStyle` property can be used to style the appearance of the row that contains the **Load More** button when the `LoadOnDemandMode` is `Manual`. |
| 56 | + |
| 57 | +The custom style is of type `Style` with target type `DataGridLoadOnDemandRowAppearance`: |
| 58 | + |
| 59 | +### Load-More-Button Row Template |
| 60 | + |
| 61 | +The `LoadOnDemandRowTemplate` property can be used to set the template of the row that contains the **Load More** button when the `LoadOnDemandMode` is `Manual`. |
| 62 | + |
| 63 | +## Examples |
| 64 | + |
| 65 | +For runnable examples with the TreeDataGrid Load On Demand options, see the [SDKBrowser Demo Application]({%slug sdkbrowser-app%}) and go to **DataGrid > Load On Demand** category. Replace the examples with `TreeDataGrid` and set a `ViewModel` and Data models with hierarchical data structrue. |
| 66 | + |
| 67 | +## Additional Resources |
| 68 | + |
| 69 | +- [.NET MAUI TreeDataGrid Product Page](https://www.telerik.com/maui-ui/treedatagrid) |
| 70 | +- [.NET MAUI TreeDataGrid Forum Page](https://www.telerik.com/forums/maui?tagId=1801) |
| 71 | +- [Telerik .NET MAUI Blogs](https://www.telerik.com/blogs/mobile-net-maui) |
| 72 | +- [Telerik .NET MAUI Roadmap](https://www.telerik.com/support/whats-new/maui-ui/roadmap) |
| 73 | + |
| 74 | +## See Also |
| 75 | + |
| 76 | +- [Sorting .NET MAUI TreeDataGrid Records]({%slug treedatagrid-sorting%}) |
| 77 | +- [Filtering .NET MAUI TreeDataGrid Records]({%slug treedatagrid-filtering-overview%}) |
0 commit comments