Filtering sfDataFrid with pagination

Hi, 

I have Winform app with SfDataGrid for displaying list of record. I have logic for filtering which works with no issues at all.

I followed the instructions in this site to implement pagination. But the filtering has introduced strange behaviour; when I comment out filtering logic, pagination works fine. These are issues.  

  • anytime I focus the search textbox, it does not matter the current, I am automatically navigate to the first page
  • the 'last page' button of the does not jump to the last page when clicked

Please find below snippets of my filter logic:   

 private void textBox2_TextChanged(object sender, EventArgs e)

        {

            if (textBox2.Text != "Search...")

            {

                FilterText = textBox2.Text;

                OnFilterChanged();

            }

        }


 private void OnFilterChanged()

        {

            if (sfDataGrid1.View != null)

            {

                sfDataGrid1.View.Filter = FilerRecords;

                sfDataGrid1.View.RefreshFilter();

            }

        }



        public bool FilerRecords(object o)

        {

            double res;

            bool checkNumeric = double.TryParse(FilterText, out res);

            var item = o as ProductListView;

            if (item != null && FilterText.Equals(""))

            {

                return true;

            }

            else

            {

                if (item != null)

                {

                    if (item.ProductCode.ToLower().Contains(FilterText) ||

                        item.ProductName.ToLower().Contains(FilterText.ToLower()) ||

                        item.ItemType.ToLower().Contains(FilterText.ToLower()) ||

                        item.Category.ToLower().Contains(FilterText.ToLower()) ||

                        item.UnitOfSale.ToLower().Contains(FilterText.ToLower()) ||

                        item.Location.ToLower().Contains(FilterText.ToLower()) ||

                        item.UnitsInStock.ToString().Contains(FilterText.ToLower()) ||

                        item.SalesPrice.ToString().Contains(FilterText.ToLower()) ||

                        item.QuantityPerUnit.ToString().Contains(FilterText.ToLower()) ||

                        item.FreeStock.ToString().Contains(FilterText.ToLower()) ||

                        item.QuantityAllocated.ToString().Contains(FilterText.ToLower()))

                        return true;


                    return false;

                }

            }


            return false;

        }


Thanks in advance for usual assistance


Regards,

Paul Aziz



11 Replies

RM Rabina Murugan Syncfusion Team November 21, 2025 12:48 PM UTC

Hi Paul,

 

We have reviewed the reported scenario and understand that you are using SfDataPager with SfDataGrid and applying filtering logic. We would like to clarify the behavior of the filtering with pagination. For example, if there are 4 pages and you are on page 3, when you enter text in the search box, the filter will apply to all records across all pages. If the page size is 3 and the filtered result contains 4 records, then the first page will display 3 filtered records and the second page will display 1 filtered record. The focus will remain in first page to show the filtered records from the beginning. This is the expected behavior and not an issue.

 

Kindly share your expected filtering requirement with pagination. Please confirm, if you need to filtering apply only to the current page while keeping other pages unchanged?

 

We have also checked the behavior of the last button of SfDataPager in the current version(v31.2.12) and the button works as expected.

 

To investigate further, please share the following details.

 

  1. The Syncfusion version you are currently using.
  2. Any customization need to replicate the last button behavior.
  3. Kindly replicate the last button issue in the attached sample and get back to us.

 

This information will help us investigate further and provide an accurate solution.

 

Find the sample demo in the attachment.

 

Regards,

Rabina M


Attachment: SfDataGrid_Pagination_522844c5.zip


PA Paul November 21, 2025 03:05 PM UTC

Hi Rabina,



Thanks so much for the reply.



Regards,

Paul A



SB Sweatha Bharathi Syncfusion Team November 24, 2025 07:45 AM UTC

Paul,

We hope that we have clarified your requirement. Please get back to us if you need any further assistance; we will be happy to help you.



PA Paul November 24, 2025 04:45 PM UTC

Hello Rabina M,


Thanks so much for the assistance. I am indeed grateful.


  1. My version of Syncfusion 22.2460.5.0
  2. I don't any customization for the last button. Just the normal behavior for displaying the page
  3. I have studied the attached example, and it works perfectly and fulfil all my requirements.

I am therefore using the example to review my filtering and pagination logic.

Thank you for your usual assistance

Regards,
Paul Aziz





RM Rabina Murugan Syncfusion Team November 25, 2025 09:33 AM UTC

Paul,

 

Thanks for the update, we will wait until we hear from you.



PA Paul November 25, 2025 06:00 PM UTC

I’m still encountering some quirks pagination and filtering. I have upgraded to version 30.1.37 and my target framework: .NET Framework 4.8

Issue Description:

  • When applying filters or navigating between pages in the grid, the behavior is inconsistent. For example:
  • Clicking the 'last page' button does not display the last page of records and filtering enable unless after several navigations.
  • Navigation works perfectly with no issues when filtering is not implemented. 

To make this clearer, I’ve attached a short screen recording demonstrating the issue step by step.


Thanks for your usual assistance



Best regards,


Paul A



Attachment: file_664914fb.rar


RM Rabina Murugan Syncfusion Team November 26, 2025 01:27 PM UTC

Paul,

 

We have investigated the reported scenario and reviewed the video you shared. In the video with filtering, when you click the last button, the page does not navigate, and the button appears disabled. However, after navigating to other pages, the last button works. It seems that the filter was not applied by entering text in the search box. To verify this, we applied the filter during the initial load and tested the last button behavior, and it worked as expected.

 

To investigate further, please share the following details.

 

  1. How are you enabling the filtering that causes the last button to behave inconsistently?
  2. Are there any customizations required to replicate the scenario?
  3. Kindly replicate the issue in the attached sample and share it with us.

 

Find the sample demo in the attachment.

 

This information will help us investigate further and provide an accurate solution.


Attachment: SfDataGrid_Demo_afb22b82.zip


PA Paul November 26, 2025 05:07 PM UTC

Hi Raina,


  1. How are you enabling the filtering that causes the last button to behave inconsistently? 

Thanks for the reply. Find my filtering logic below:


 private void textBox2_TextChanged_1(object sender, EventArgs e)

        {


            var textBox = sender as System.Windows.Forms.TextBox;

            if (textBox.Text != "Search...")

            {

                FilterText = textBox.Text;

                OnFilterChanged();

                textBox2.Focus();

            }

        }


   private void OnFilterChanged()

        {

            if (sfDataGrid1.View != null)

            {

                sfDataGrid1.View.Filter = FilerRecords;

                sfDataGrid1.View.RefreshFilter();

            }

      }


        public bool FilerRecords(object o)

        {

            var item = o as ProductListView;

            if (item != null && string.IsNullOrEmpty(FilterText))

            {

                return true;

            }

            else if (item != null)

            {

                if (item.ProductCode.ToString().Contains(FilterText) ||

                    item.ProductName.ToLower().Contains(FilterText.ToLower()) ||

                    item.ItemType.ToLower().Contains(FilterText.ToLower()) ||

                    item.Barcode.ToLower().Contains(FilterText.ToLower()) ||

                    item.Location.ToString().Contains(FilterText))

                {

                    return true;

                }

                return false;

            }

            return false;

        }


2Are there any customizations required to replicate the scenario?

I don't require any customization, I just want records paginated and filterable. 

3. Kindly replicate the issue in the attached sample and share it with us

I have replicated the attached sample in my project, but I get the same inconsistent behavior. I am however, still investigating the to Identify what the problem is.


Thank you for your usual assistance. I am very grateful.


Regards,

Paul Aziz



RM Rabina Murugan Syncfusion Team November 27, 2025 12:36 PM UTC

Paul,

 

We have reviewed the code you provided and there is no issue with that. In your last update, you mentioned as last page button does not work correctly when filtering is applied, but in your provided video reference (with-filtering video file), we couldn't find that filtering action. So that we request about how you are applying the filter (either on-loading or through text box). 

 

Based on your code, filtering is triggered in the TextChanged event of the textbox, which means filtering occurs only when text is entered. We have tested by applying the filter programmatically and also entering the text in the TextBox, but we unable to replicate the issue at our end.

 

Please refer to the below video for our test results.

 

 

To investigate further, please share the following details:

 

  1. A reproducible sample that demonstrates the issue.
  2. A step-by-step procedure to replicate the issue.

 

Without reproducing the issue, we cannot provide an accurate solution. So kindly replicate the issue in our sample and share it back with us.

 

Find the sample demo in the attachment.

 

This information will help us investigate further and provide an accurate solution.


Attachment: SfDataGrid_Filter_Pagination_54115ebc.zip


PA Paul December 17, 2025 10:10 AM UTC

Hello Rabina,


Thanks for your patience and assistance.


The culprit was this line of code below in the Form_Shown event:  textBox2.Text = "Search...";


I am indeed grateful to you.


Best reagrds,

Paul




SR Senthilkumar Ranganathan Syncfusion Team December 18, 2025 08:00 AM UTC

Paul,

We glad that the query was addressed from your side. If you have any other queries, please create a new forum. Hence, we are closing this forum.


Loader.
Up arrow icon