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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

search in one column of a sfdatagrid

Thread ID:





128241 Jan 10,2017 01:48 PM UTC Jan 11,2017 04:03 PM UTC WPF 1
Tags: SfDataGrid
Philipp Reiter
Asked On January 10, 2017 01:48 PM UTC

I have a sfDataGrid with three GridTextColumn and two GridTemplateColumn.CellTemplate (DatePiker) columns. I want to search and programmatically select in the first column (which is a GridTextColumn). Using the SearchHelper.Search fails with NullReferenceExceptions. I think they are cause from searching over the GridTemplateColumn.

Is it possible to point the SearchHelper to the first column only?

Or how can I export a list from the first column only to search in manually?

Thanks in advance, Philipp


Gnanasownthari Thirugnanam [Syncfusion]
Replied On January 11, 2017 04:03 PM UTC

Hi Philipp, 

We have analyzed your query. We are unable to reproduce your reported issue “Nullreference Exception throws ” when search and programmatically select the first column (GridTexColumn). You can achieve your requirement in below mentioned way. 

Query 1: Possible to point the SearchHelper to the first column 
You can achieve your requirement customize the SearchHelper class and  search first column only based on mapping name like below code example. 

Code Example (C#): 
public MainWindow() 
    this.dataGrid.SearchHelper = new SearchHelperExt(this.dataGrid);            
public class SearchHelperExt : SearchHelper 
    public SearchHelperExt(SfDataGrid datagrid) 
        : base(datagrid) 
    protected override bool SearchCell(DataColumnBase column, object record, bool ApplySearchHighlightBrush) 
        if (column == null) 
            return false; 
        if (column.GridColumn.MappingName == "OrderID") 
            return base.SearchCell(column, record, ApplySearchHighlightBrush); 
            return false; 

Query 2: Export a list from the first column only to search in manually 
Export the searched record like below code example 
Code Example (C#): 
private void Shift_Click(object sender, RoutedEventArgs e) 
    var recored = this.dataGrid.SelectedItem;            
    var viewmodel = this.dataGrid.DataContext as ViewModel; 
    if (previousrowColumnIdex != this.dataGrid.SearchHelper.CurrentRowColumnIndex) 
    previousrowColumnIdex = this.dataGrid.SearchHelper.CurrentRowColumnIndex;            

We have prepared the sample as per your requirement , you can download the same from below mentioned location. 

Sample location: 

Gnanasownthari T.  



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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