)
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

How to apply search and filter for one column in SfDataGrid?

Platform: WPF |
Control: SfDataGrid |
Published Date: September 19, 2018 |
Last Revised Date: September 21, 2018

You can apply the searching operation for one column by inheriting SearchHelper class in SfDataGrid and overriding the SearchCell and FilterRecords methods.

In the sample, the searching operation has been performed for EmployeeId column based on the text entered in the text box and when the text box lost its focus or pressed the Enter key in the text box.

Refer to the following code snippets to apply the search filter for one column in SfDataGrid.

XAML

 

SerachHelperExt.cs                                                             

 

MainWindow.xaml.cs

 

Sample:

WPF

 

 

 

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
EloIT
Mar 20, 2019

This solution doesn't work for FindNext() and FindPrevious() methods.

Reply
Deivaselvan Y [Syncfusion]
Mar 27, 2019

Hi EloIT,

We have analyzed your query to perform FindNext and FindPrevious operation using search in one column. You can achieve this by overriding MatchSearchText in SearchHelperExt class as like below code snippet.

public class SearchHelperExt : SearchHelper 
{ 
protected override bool MatchSearchText(GridColumn column, object record) 
{ 
            if(column.MappingName == "EmployeeId") 
                return base.MatchSearchText(column, record); 
            return false; 
} 
} 

private void NextButton_Click(object sender, RoutedEventArgs e) 
        { 
            this.dataGrid.SearchHelper.FindNext(this.TextBox.Text); 
            this.dataGrid.SelectionController.MoveCurrentCell(this.dataGrid.SearchHelper.CurrentRowColumnIndex); 
        } 


        private void PrevButton_Click(object sender, RoutedEventArgs e) 
        { 
            this.dataGrid.SearchHelper.FindPrevious(this.TextBox.Text); 
            this.dataGrid.SelectionController.MoveCurrentCell(this.dataGrid.SearchHelper.CurrentRowColumnIndex); 
        }

Please find sample for the same from the below link

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/231305/ze/SearchingDemo133402893

Please let us know, if you need any further assistance on this.

Regards, Deivaselvan

Please sign in to access our KB

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

Up arrow icon

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