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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

143202 Mar 8,2019 02:48 PM UTC Mar 15,2019 03:50 AM UTC Xamarin.Forms 2
loading
Tags: SfListView
Mario
Asked On March 8, 2019 02:48 PM UTC

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);
}
}

Deivaselvan Y [Syncfusion]
Replied On 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 


Deivaselvan Y [Syncfusion]
Replied On 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 


CONFIRMATION

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon