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()
{
InitializeComponent();
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);
}
else
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)
{
this.dataGrid.SearchHelper.FindNext(this.TextBox.Text);
this.dataGrid.SelectionController.MoveCurrentCell(this.dataGrid.SearchHelper.CurrentRowColumnIndex);
var recored = this.dataGrid.SelectedItem;
var viewmodel = this.dataGrid.DataContext as ViewModel;
if (previousrowColumnIdex != this.dataGrid.SearchHelper.CurrentRowColumnIndex)
viewmodel.SearchItem.Add(recored);
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:
Regards,
Gnanasownthari T.