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

Binding to datapager data doesn't display

Hi I have followed the examples here to try and create paging in my datagrid. The paging controls show and I have bound to the pager in the code behind but my datagrid shows nothing. Any help appreciated. (PlayerList is an ObservableCollection)

public MainView()
        {
            InitializeComponent();
            this.PlayerDataGrid.ItemsSource = sfDataPager.PagedSource;
        }

XAML
        <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <Grid HorizontalOptions="FillAndExpand"  VerticalOptions="FillAndExpand">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

            <sfpager:SfDataPager x:Name ="sfDataPager"
                           Grid.Row="0"           
                           PageSize="10" 
                           HeightRequest ="50"
                           NumericButtonCount="10"
                           Source="{Binding PlayerList}">
            </sfpager:SfDataPager>
            
                <datagrid:SfDataGrid x:Name="PlayerDataGrid"
                             HorizontalOptions="FillAndExpand"    
                             VerticalOptions="FillAndExpand"
                             AutoGenerateColumns="False"
                                 ColumnSizer="Star"
                                 AllowSorting="True"
                                 AllowTriStateSorting="True"
                                 AllowMultiSorting="True"
                                     Grid.Row="1"
                                     SelectionMode="Single"
                                     SelectionChanged="PlayerDataGrid_SelectionChanged"
                                     AllowPullToRefresh ="True"
                                    PullToRefreshCommand="{Binding RefreshCommand}"
                                     IsBusy="{Binding IsBusy}"
                                     >
                    <datagrid:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns">
                        <datagrid:GridTextColumn HeaderText="Name" 
                                             MappingName="FirstName" />
                        <datagrid:GridTextColumn HeaderText="Surname"
                                             MappingName="LastName" />
                        <datagrid:GridTextColumn HeaderText="Guardian" 
                                             MappingName="ParentFName" />
                        <datagrid:GridTextColumn HeaderText="Phone"
                                             MappingName="PhoneNum" />
                        <datagrid:GridTextColumn HeaderText="Team"
                                             MappingName="PlayersTeam.TeamName"/>
                    </datagrid:SfDataGrid.Columns>

                    <datagrid:SfDataGrid.SortColumnDescriptions>
                        <datagrid:SortColumnDescription ColumnName="FirstName" 
                                          SortDirection="Ascending" />
                        <datagrid:SortColumnDescription ColumnName="LastName" 
                                          SortDirection="Ascending" />
                        <datagrid:SortColumnDescription ColumnName="PlayersTeam.TeamName" 
                                          SortDirection="Ascending" />
                    </datagrid:SfDataGrid.SortColumnDescriptions>



                </datagrid:SfDataGrid>
            
        </Grid>
        </StackLayout>

1 Reply

DS Divakar Subramaniam Syncfusion Team December 12, 2016 06:28 AM UTC

Hi Ciaran, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query and we were not able to reproduce the reported issue on our side. We have prepared a simple sample using SfDataPager and SfDataGrid controls and also applied the code you have provided in your update and the SfDatagrid was loading fine with data. 
 
We have attached our sample for your sample and you can download the same from the below link. 
 
Please ensure that in order to load the SfDataGid in Forms.iOS platform, you need to initialize the SfDataGrid in Forms.iOS project as like in below code snippet. 
// In AppDelegate.cs 
         
using Syncfusion.SfDataGrid.XForms.iOS; 
 
public override bool FinishedLaunching(UIApplication app, NSDictionary options) 
{ 
    global::Xamarin.Forms.Forms.Init(); 
    LoadApplication(new App()); 
 
    SfDataGridRenderer.Init(); 
 
    return base.FinishedLaunching(app, options); 
} 
 
 
 
Regards, 
Divakar. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon