We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Paging LoadDynamicItems not work

Thread ID:





131429 Jul 9,2017 02:33 AM Jul 10,2017 05:58 AM Xamarin.Forms 1
Tags: SfDataGrid
Michael Chan
Asked On July 9, 2017 02:33 AM

Hi all,

Who can help me fix this problem.
This is my code for using SfDataGrid with UseOnDemandPaging.

using Syncfusion.SfDataGrid.XForms;
using Syncfusion.SfDataGrid.XForms.DataPager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace HelloSyncfusion
    public partial class MainPage : ContentPage
        SfDataGrid sfGrid = new SfDataGrid();

        SfDataPager sfDataPager = new SfDataPager();

        StackLayout parent = null;
        VE_VESSEL_INFO_Repository resposity = new VE_VESSEL_INFO_Repository();
        public MainPage()

            //sfGrid.ItemsSource = new OrderInfoRepository().OrderInfoCollection;  //Setting ItemsSource to SfDataGrid
            sfGrid.ColumnSizer = ColumnSizer.Star;

            Grid myGrid = new Grid();
            myGrid.HorizontalOptions = LayoutOptions.FillAndExpand;

            myGrid.RowDefinitions = new RowDefinitionCollection
              new RowDefinition { Height = 50 },
              new RowDefinition {},

            sfDataPager.OnDemandLoading += SfDataPager_OnDemandLoadingAsync;
            sfDataPager.UseOnDemandPaging = true;

            sfDataPager.PageSize = 5;
            sfGrid.ItemsSource = sfDataPager.PagedSource;

            myGrid.Children.Add(sfDataPager, 0, 0);
            myGrid.Children.Add(sfGrid, 0, 1);
            this.Content = myGrid;

        private async void SfDataPager_OnDemandLoadingAsync(object sender, OnDemandLoadingEventArgs args)
            //throw new NotImplementedException();
            var vesseles = await resposity.GetCollection(); //List<object> --> Debug: OK, list count = 12

But result don't show data, and paging as attached image

Ashok N [Syncfusion]
Replied On July 10, 2017 05:58 AM

Hi Michael, 
Thanks for contacting Syncfusion support. 
We have checked your code snippet and you didn’t bind the SfDataGrid.ItemsSource , instead of you are set the SfDataPager.PagedSource is ItemsSource of SfDataGrid. For OnDemandLoading initially PagedSource was null, and based on the PagedSource only we are setting the ItemsSource to SfDataGrid in Paging. You can achieve your requirement by Binding PagedSource as ItemsSource to SfDataGrid. Please refer the below Code example:  
public partial class SfDataGridPage : ContentPage 
    private OrderInfoRepository repository; 
    private ObservableCollection<OrderInfo> source; 
    public SfDataGridPage() 
        repository = new OrderInfoRepository(); 
        source = repository.GetOrderDetails(200); 
        this.dataPager.OnDemandLoading += DataPager_OnDemandLoading; 
        this.dataGrid.SetBinding(SfDataGrid.ItemsSourceProperty, new Binding() { Path = "PagedSource", Source = this.dataPager }); 
    private void DataPager_OnDemandLoading(object sender, OnDemandLoadingEventArgs args) 
        dataPager.LoadDynamicItems(args.StartIndex, viewModel.OrdersInfo.Skip(args.StartIndex).Take(args.PageSize)); 
Please refer the below Sample for more reference , 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.