SfDataPager allows you to load the data for the current page, in OnDemandPaging, at runtime. You can enable OnDemandPaging by setting SfDataPager.UseOnDemandPaging to True. The data for the current page needs to be loaded in SfDataPager.OnDemandLoading event via SfDataPager.LoadDynamicItems method. When using OnDemandPaging, you may have to read data from some external server sometimes, it takes some time to read the data. In this case, you can delay the loading in SfDataPager.OnDemandLoading event by using async and await. The following section shows you how to load the data with some delay in OnDemandPaging using async and await. Here, SfDataPager and SfDataGrid are defined and SfDataGrid.ItemsSource is bound to SfDataPager.PagedSource. Also OnDemandLoading event is hooked for SfDataPager. XAML
The OnDemandLoading event is triggered when the pager moves to the corresponding page. The OnDemandLoading event contains the following event arguments:
Here dataPager_OnDemandLoading is defined with async keyword to await data loading. Inside dataPager_OnDemandLoading, GetEmployeesDetailsListAync method is called with await keyword and the execution is stopped here until GetEmployeesDetailsListAync returns the data. GetEmployeesDetailsListAync returns the data for the page with some delay. Note: Here data is returned with some delay in GetEmployeesDetailsListAync method using Thread.Sleep method. C# Note: The above code shows build error in WinRT platform as the Thread.Sleep method is not supported in WinRT. Use Task.Delay to delay the data loading in WinRT as shown in the following code snippet. WinRT and UWP code Sample Links:
|
This page will automatically be redirected to the sign-in page in 10 seconds.