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. Image for the cookie policy date

SfDataPager - System.ArgumentException: source is not IEnumerable<>

I have a SFDataList and SFDataPager and using the Load on demand feature. In theOnDemandLoading event handler I load data from a Rest Web Api. and then invoke LoadDynamicItems on the dataPager. An exception is thrown a that my collection is notIEnumerable<> which it is.
Xaml:
  <syncfusion:SfListView x:Name="listView"                            
                            ItemSize="100"                        
                            SelectionMode="Single"
                            SelectionGesture="Tap"
                            SelectionBackgroundColor="#E4E4E4"
                            IsStickyHeader="true"
                            Grid.Row="1"
                            ItemsSource="{Binding PagedSource, Source={x:Reference dataPager}}">

                        <syncfusion:SfListView.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="0.4*" />
                                        <RowDefinition Height="0.3*" />
                                    </Grid.RowDefinitions>
                                    <Label Text="{Binding Number}" FontAttributes="Bold" TextColor="Teal" FontSize="21" />
                                    <Label Grid.Row="1" Text="{Binding EstimatedValue}" TextColor="Teal" FontSize="15"/>
                                </Grid>
                            </DataTemplate>
                        </syncfusion:SfListView.ItemTemplate>
                    </syncfusion:SfListView>

                    <sfPager:SfDataPager x:Name="dataPager" 
                                         UseOnDemandPaging="True" 
                                         DisplayMode = "PreviousNextNumeric" 
                                         NumericButtonCount = "4" 
                                         HorizontalOptions="Center"
                                         Grid.Row="2"
                                         PageCount="60" />

Behaviour:
public class SfListViewPagingBehavior : Behavior
{
private Syncfusion.ListView.XForms.SfListView listView;
private RequisitionListViewModel viewModel;
private SfDataPager dataPager;
private IList Items { get; set; }
public IFinanceRestService FinanceRestService => DependencyService.Get() ?? new FinanceRestService();

public SfListViewPagingBehavior()
{
Items = new ObservableCollection();
}
protected override void OnAttachedTo(ContentPage bindable)
{
listView = bindable.FindByName("listView");
dataPager = bindable.FindByName("dataPager");
viewModel = new RequisitionListViewModel();
dataPager.OnDemandLoading += DataPager_OnDemandLoading;
base.OnAttachedTo(bindable);
}
private void DataPager_OnDemandLoading(object sender, OnDemandLoadingEventArgs e)
{
try
{
AsyncUtil.RunSync(() => ExecuteLoadItemsAsync(e.StartIndex));
var items = this.Items.AsEnumerable();
dataPager.LoadDynamicItems(e.StartIndex, items);
}
catch(Exception ex)
{
}
}
public async Task ExecuteLoadItemsAsync(int pageIndex)
{
try
{
Items.Clear();
var searchResult = await this.FinanceRestService.GetRequisitions();
foreach (var item in searchResult.SearchResults)
{
Items.Add(item);
}
}
catch (Exception ex)
{
await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK");
Debug.WriteLine(ex);
}
}
protected override void OnDetachingFrom(ContentPage bindable)
{
listView = null;
viewModel = null;
dataPager = null;
base.OnDetachingFrom(bindable);
}
}

2 Replies

DY Deivaselvan Y Syncfusion Team March 13, 2019 07:00 AM UTC

Hi Mario,

Thank you for contacting Syncfusion support.

We can reproduce the reported issue at our end and we have forwarded this issue to our development team for further analysis. We will update you with more details on March 14, 2019.

Regards,
Deivaselvan 



DY Deivaselvan Y Syncfusion Team March 15, 2019 03:50 AM UTC

Hi Mario,


We have validated the defect you have initiated with us. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our subsequent 2019 Volume 1 Service Pack 1 release. If you wish to receive this fix in a specific prior release product version please contact Syncfusion Support(backwards compatibility subject to technological feasibility and our Support SLA) You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.


Regards,
 
Deivaselvan 


Loader.
Live Chat Icon For mobile
Up arrow icon