Combining search with additional programmatic filters

Hi,

I currently have a datagrid with the built-in text search function which filters out visible rows according to the search text (no highlighting).

I have created additional textboxes to filter on other properties for each row. I want to be able to use the text search function together with programmatic filters on other properties. For example, search for text "apple" and also only show rows where MyRowProperty > 5.

I have learnt that I cannot use the search function together with column filters. I was thinking of maybe filtering the data myself before SfDataGrid handles the data by wrapping the items source in some kind of filterable view, but I'm not sure if this would work.

Please advise me on how I could achieve this?

Kind regards,
Zia


3 Replies 1 reply marked as answer

SB Sweatha Bharathi Syncfusion Team November 12, 2025 10:00 AM UTC

Hi Zia,

We have reviewed your query. Based on the information you provided, we understand that you are combining column filters with a search functionality. To replicate your scenario, we have prepared a simple sample using a textbox and a button click event. In this example, the search text is set to "ANATR", and it is combined with a filter predicate where the UnitPrice column value is greater than 200.

When "ANATR" is entered in the textbox and the button is clicked, the filter predicates for the UnitPrice column are applied, and the search method is invoked for the SfDataGrid. Additionally, filtering is enabled for the SearchHelper within the button click event. As a result, the row containing "ANATR" will be displayed only if its UnitPrice is greater than 200. This functionality is working fine as expected.

Code snippet to combine column filtering with search functionality:

private void search_Click(object sender, RoutedEventArgs e)
{
    datagrid.Columns["UnitPrice"].FilterPredicates.Add(new FilterPredicate() { FilterType = FilterType.GreaterThan, FilterValue = 200 });
    datagrid.SearchHelper.AllowFiltering = true;
    datagrid.SearchHelper.Search(textBox.Text);
}

When filtering is disabled for the SearchHelper, it only highlights the searched text. The filtering logic is applied separately, so only the rows where the column value is greater than 200 are displayed, as shown below.

Image Reference without using Filter for SearchHelper:


When filtering is enabled for the SearchHelper, it highlights the searched text. The filtering logic is applied so that only the rows containing the search text "ANATR" and having a UnitPrice value greater than 200 are displayed, as shown below.

Image Reference when enabling Filter for SearchHelper:


UG Link:
Search

We have provided a sample for your reference. Kindly review the sample, and if you are still facing issues, please provide the following details:

1.Could you please confirm how you are enabling filtering and search together? 
2.Are you expecting the filtering to be applied automatically when the search method is invoked? 
3.please clarify the exact scenario you are expecting.
4.Kindly modify the provided sample to replicate your exact scenario.

Regards,
Sweatha B

Attachment: sample_45cb3633.zip

Marked as answer

ZI Zia November 12, 2025 03:27 PM UTC

Hi,

Thanks for your help. I combined the column filters and search filter and got it working.

After further investigation, it turned out that an optimisation I had made was interfering with the expected filter result:

  • My optimisation was to disable computation of the values for rows that were not visible on the screen. 
  • Therefore as I was filtering using the column filter, I was not seeing the expected results because rows were going out of view and their values were being removed.
Zia


RM Rabina Murugan Syncfusion Team November 13, 2025 01:11 PM UTC

Hi Zia,

 

We have investigated the reported scenario and understand that the unexpected results are occurring due to the optimization you implemented. However, we are a slightly unclear about the exact details of your scenario.

 

To assist you further, please provide the following information:

 

  1. A detailed explanation of how you are disabling the calculation for rows that are not visible.
  2. The code snippet related to this optimization.
  3. Kindly replicate the scenario in the previously shared sample so we can analyze it in context.

 

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

 

Regards,

Rabina M


Loader.
Up arrow icon