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
close icon

Is there a way to determine in which page of a paginated grid a record is?

I have a paginated SfDataGrid binded to a collection of records using SfDataPager.
I'd like, at runtime (by code), to move to a particular page where a particular record is displayed.
Is there a method to determine by code in which page number a particular record is actually displayed ?

1 Reply

SA Saravanan Ayyanar Syncfusion Team January 14, 2020 01:07 PM UTC

Hi Silvio, 
Thank you for using Syncfusion controls. 
We have checked your reported scenario. You can achieve your requirement by getting the PagedCollectionView.InternalList. Using this internal list you can calculate the PageIndex using SfDataPager.PageSize property.  It working same as for while sorting the SfDataGrid. Please refer the below code snippet. 
private void Button_Click(object sender, RoutedEventArgs e) 
    var collection = (this.dataGrid.View as PagedCollectionView).GetInternalList(); 
    int i = 0; 
    foreach (var rec in collection) 
        var value = (rec as OrderInfo).OrderID; 
        if ((int)value == 1019) 
            int index = i / this.sfDataPager.PageSize; 
            this.sfDataPager.PageIndex = index; 
            this.dataGrid.SelectedIndex = i % this.sfDataPager.PageSize; 
            var rowindex = this.dataGrid.ResolveToRowIndex(this.dataGrid.SelectedIndex); 
            var visualcontainer = this.dataGrid.GetVisualContainer(); 
Sample Link: 
Please let us know, if you require further assistance on this. 
Saravanan A. 

Live Chat Icon For mobile
Up arrow icon