Class SearchHelper
Represents the Search operation which is performed in the DataGrid.
Inheritance
Namespace: Syncfusion.UI.Xaml.Grid
Assembly: Syncfusion.SfGrid.WPF.dll
Syntax
public class SearchHelper : DependencyObject, INotifyDependencyPropertyChanged, IDisposable
Remarks
The SearchHelper provides a flexible way to search the text in the DataGrid.
Constructors
SearchHelper(SfDataGrid)
Invokes when new instances has been created.
Declaration
public SearchHelper(SfDataGrid sfDataGrid)
Parameters
| Type | Name | Description |
|---|---|---|
| SfDataGrid | sfDataGrid |
Fields
AllowCaseSensitiveSearchProperty
Identifies the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.AllowCaseSensitiveSearch dependency property.
Declaration
public static readonly DependencyProperty AllowCaseSensitiveSearchProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Remarks
The identifier for the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.AllowCaseSensitiveSearch dependency property.
AllowFilteringProperty
Identifies the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.AllowFiltering dependency property.
Declaration
public static readonly DependencyProperty AllowFilteringProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Remarks
The identifier for the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.AllowFiltering dependency property.
CanHighlightSearchTextProperty
Declaration
public static readonly DependencyProperty CanHighlightSearchTextProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
DataGrid
Gets the Datagrid
Declaration
protected SfDataGrid DataGrid
Field Value
| Type |
|---|
| SfDataGrid |
Provider
Gets the provider to reflect the cell value.
Declaration
protected IPropertyAccessProvider Provider
Field Value
| Type |
|---|
| IPropertyAccessProvider |
SearchBrushProperty
Identifies the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.SearchBrush dependency property.
Declaration
public static readonly DependencyProperty SearchBrushProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Remarks
The identifier for the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.SearchBrush dependency property.
SearchForegroundBrushProperty
Identifies the SearchForegroundBrush dependency property.
Declaration
public static readonly DependencyProperty SearchForegroundBrushProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Remarks
The identifier for the SearchForegroundBrush dependency property.
SearchForegroundHighlightBrushProperty
Identifies the SearchForegroundHighlightBrush dependency property.
Declaration
public static readonly DependencyProperty SearchForegroundHighlightBrushProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Remarks
The identifier for the SearchForegroundHighlightBrush dependency property.
SearchHighlightBrushProperty
Identifies the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.SearchHighlightBrush dependency property.
Declaration
public static readonly DependencyProperty SearchHighlightBrushProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Remarks
The identifier for the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.SearchHighlightBrush dependency property.
SearchTextProperty
Declaration
public static readonly DependencyProperty SearchTextProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
SearchTypeProperty
Identifies the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.SearchType dependency property.
Declaration
public static readonly DependencyProperty SearchTypeProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Remarks
The identifier for the Syncfusion.UI.Xaml.Grid.SfDataGrid.SearchHelper.SearchType dependency property.
Properties
AllowCaseSensitiveSearch
Gets or sets a value that enables case-sensitive string comparison during search in SfDataGrid. ///
Declaration
public bool AllowCaseSensitiveSearch { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | true if the case sensitive search enabled; otherwise, false. The default value is false. |
AllowFiltering
Gets or sets a value that indicates whether to enable filter based on search text.
Declaration
public bool AllowFiltering { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | true if the DataGrid is filtered when Search is called. Otherwise, false. The default value is false. |
CanHighlightSearchText
Gets or sets a value that indicates whether to highlight the search text or not.
Declaration
public bool CanHighlightSearchText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | true, if the search text is highlighted; otherwise,false. The default value is true. |
CurrentRowColumnIndex
Declaration
public RowColumnIndex CurrentRowColumnIndex { get; set; }
Property Value
| Type |
|---|
| RowColumnIndex |
SearchBrush
Gets or sets a brush to highlight search text in SfDataGrid.
Declaration
public Brush SearchBrush { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Media.Brush | The background color of the SearchText in the GridCell. The default value is Yellow. |
SearchForegroundBrush
Gets or sets a brush to highlight search text foreground.
Declaration
public Brush SearchForegroundBrush { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Media.Brush | The foreground color of the SearchText in the GridCell. The default value is Black. |
SearchForegroundHighlightBrush
Gets or sets a brush that highlights the search text foreground of a cell during FindNext(String) and FindPrevious(String) method calls.
Declaration
public Brush SearchForegroundHighlightBrush { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Media.Brush | The foreground color of the SearchText in the GridCell when FindNext(String) or FindPrevious(String) is called.The default value is Black |
SearchHighlightBrush
Gets or sets a brush that highlights the search text of a cell during FindNext and FindPrevious method calls.
Declaration
public Brush SearchHighlightBrush { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Media.Brush | The background color of the SearchText in the GridCell when FindNext or FindPrevious is called. |
SearchText
Gets the text which is used to search the DataGrid.
Declaration
public string SearchText { get; set; }
Property Value
| Type |
|---|
| System.String |
SearchType
Gets or sets the
Declaration
public SearchType SearchType { get; set; }
Property Value
| Type | Description |
|---|---|
| SearchType | One of the enumeration specifying the SearchType. The default value is Syncfusion.UI.XAML.Grid.SearchType.Contains |
Methods
ApplyInline(DataColumnBase, Object, Boolean)
Sets the background color for search text in TextBlock.
Declaration
protected virtual bool ApplyInline(DataColumnBase column, object data, bool ApplySearchHighlightBrush)
Parameters
| Type | Name | Description |
|---|---|---|
| DataColumnBase | column | Denotes the column being searched. |
| System.Object | data | Gets the corresponding cell value. |
| System.Boolean | ApplySearchHighlightBrush |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true, if background changed for the search text in TextBlock. otherwise false. |
ClearSearch()
Clears the text highlighting in the searched TextBlock’s of SfDataGrid.
Declaration
public virtual void ClearSearch()
ClearSearchCell(DataColumnBase, Object)
Clears highlighting in the specified GridCell.
Declaration
protected virtual void ClearSearchCell(DataColumnBase column, object record)
Parameters
| Type | Name | Description |
|---|---|---|
| DataColumnBase | column | Denotes the column associated with cell. |
| System.Object | record | Denotes the data object associated with cell. |
ClearSearchRow(DataRowBase)
Clears the highlighting in the searched TextBlock’s of DataRow.
Declaration
protected virtual void ClearSearchRow(DataRowBase row)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRowBase | row | Specifies the corresponding DataRow. |
Dispose()
Releases the allocated resources used by the SearchHelper class.
Declaration
public void Dispose()
Dispose(Boolean)
Releases the allocated resources used by the SearchHelper class.
Declaration
protected virtual void Dispose(bool isDisposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | isDisposing | Indicates whether the call is from Dispose method or from a finalizer. |
FilterRecords(Object)
Returns whether row match with search text to filter SfDataGrid based on search text.
Declaration
protected virtual bool FilterRecords(object dataRow)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | dataRow | Denotes the data object . |
Returns
| Type |
|---|
| System.Boolean |
FindNext(String)
Finds and highlights, the next cell match with search text and updates CurrentRowColumnIndex.
Declaration
public virtual bool FindNext(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | Specifies the text to be searched. |
Returns
| Type |
|---|
| System.Boolean |
FindPrevious(String)
Find and highlights, the previous cell match with search text and updates CurrentRowColumnIndex.
Declaration
public virtual bool FindPrevious(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | Specifies the text to be searched. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true, if any of the previous cell match with search text. Otherwise false. |
GetSearchRecords()
Search and returns the collection of GridSearchInfo.
Declaration
public List<GridSearchCellInfo> GetSearchRecords()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<GridSearchCellInfo> | Returns list of GridSearchCellInfo. |
HorizontalScrollinView(Int32)
Scrolls the columns horizontally when the column is clipped.
Declaration
protected void HorizontalScrollinView(int columnIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | columnIndex |
MatchSearchText(GridColumn, Object)
Checks whether the cell display text with the SearchText.
Declaration
protected virtual bool MatchSearchText(GridColumn column, object record)
Parameters
| Type | Name | Description |
|---|---|---|
| GridColumn | column | Denotes the column being searched. |
| System.Object | record | Denotes the data object being searched |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true, if cell display text match with search text. Otherwise false. |
OnDependencyPropertyChanged(String, DependencyPropertyChangedEventArgs)
Declaration
public void OnDependencyPropertyChanged(string propertyName, DependencyPropertyChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyName | |
| System.Windows.DependencyPropertyChangedEventArgs | e |
ParentGridScrollInView(Int32)
Method which helps to scroll the particular row into view in DetailsViewDataGrid.
Declaration
protected void ParentGridScrollInView(int rowIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | rowIndex | The row index to bring into view. |
ProcessDetailsViewFindNext(Int32, String, SfDataGrid)
Searches and highlights, the next cell that match with search text.
Declaration
protected bool ProcessDetailsViewFindNext(int rowIndex, string relationalColumn, SfDataGrid sourceDataGrid = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | rowIndex | The row index to find the next DetailsViewDataGrid |
| System.String | relationalColumn | |
| SfDataGrid | sourceDataGrid |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true, if the search text matches with any cell in DetailsViewDataGrid. otherwise false |
ProcessDetailsViewFindPrevious(Int32, String, SfDataGrid)
Searches and highlights, the previous cell that match with search text.
Declaration
protected bool ProcessDetailsViewFindPrevious(int rowIndex, string relationName, SfDataGrid sourceDataGrid = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | rowIndex | The row index to find the next DetailsViewDataGrid |
| System.String | relationName | |
| SfDataGrid | sourceDataGrid |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true, if the search text matches with any cell in DetailsViewDataGrid. otherwise false |
ProcessDetailsViewNextIndex(SfDataGrid, String)
Searches the next row index match with search text in DetailsViewDataGrid.
Declaration
protected bool ProcessDetailsViewNextIndex(SfDataGrid sfDataGrid, string relationName)
Parameters
| Type | Name | Description |
|---|---|---|
| SfDataGrid | sfDataGrid | The SfDataGrid associated with all DetailsViewDataGrid in that level. |
| System.String | relationName |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true, if the search text matched in DetailsViewDataGrid, otherwise false. |
ProcessDetailsViewPreviousIndex(SfDataGrid, String)
Searches the previous row index match with search text in DetailsViewDataGrid.
Declaration
protected bool ProcessDetailsViewPreviousIndex(SfDataGrid sfDataGrid, string relationName)
Parameters
| Type | Name | Description |
|---|---|---|
| SfDataGrid | sfDataGrid | The SfDataGrid associated with all DetailsViewDataGrid in that level. |
| System.String | relationName |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true, if the search text matched in DetailsViewDataGrid, otherwise false. |
ResumeUpdates()
Resumes usual search operation in SfDataGrid
Declaration
protected void ResumeUpdates()
Search(String)
Initiates the Search operation in SfDataGrid based on passed text.
Declaration
public virtual void Search(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | Specifies the text to be Search. |
SearchCell(DataColumnBase, Object, Boolean)
Looks for the SearchText in the TextBlocks of the cell and invokes ApplyInline to set the background color for the search text in TextBlock.
Declaration
protected virtual bool SearchCell(DataColumnBase column, object record, bool ApplySearchHighlightBrush)
Parameters
| Type | Name | Description |
|---|---|---|
| DataColumnBase | column | Denotes the GridColumn associate with cell. |
| System.Object | record | Denotes the data object associated with cell. |
| System.Boolean | ApplySearchHighlightBrush |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the brush value is applied to the TextBlock inlines. |
SearchRow(DataRowBase)
Searches the cells in the row to match with the SearchText.
Declaration
protected virtual void SearchRow(DataRowBase row)
Parameters
| Type | Name | Description |
|---|---|---|
| DataRowBase | row | Specifies the DataRow to search. |
SuspendUpdates()
Temporarily suspends the updates for the search operation in SfDataGrid.
Declaration
protected void SuspendUpdates()