Searching a grid with huge data source can be a tedious task even in a grid that supports column filtering and sorting. To make this task easier, FlexGrid supports searching the entire data source connected to the grid through full text filtering. To apply full text filtering, you need to use BindingPaths property of the FullTextFilterCondition class, which specifies the data column(s) that will participate in the full text search filtering. For searching, you can use an editor control to act as a search box where user provides the input for obtaining the search results. You need to handle an event depending on whether you want to search as the user types in or once the input has completed. In that event, you can invoke ApplyFullTextFilter method of the C1CollectionView class which accepts input text and instance of the FullTextFilterCondition class as its parameters.
In addition, the FullTextFilterCondition class provides conditions to perform full text search filtering in the control. These conditions can be applied to the user input for customizing the filtering behavior using the MatchCase, MatchWholeWord and TreatSpacesAsAndOperator properties.
In the following example, we used a TextBox as a search box and invoked the ApplyFullTextFilter method in TextChanged event of the TextBox to implement full text search filtering in FlexGrid.
XAML |
Copy Code
|
---|---|
<Grid> <TextBox x:Name="filterTextBox" HorizontalAlignment="Left" VerticalAlignment="Top" TextChanged="filterTextBox_TextChanged" Margin="0,20,0,0" Width="250"/> <Custom:C1FlexGrid x:Name="c1FlexGrid1" HorizontalAlignment="Left" AutoGenerateColumns="false" ColumnHeaderForeground="Black" Margin="0,60,0,0"> <Custom:C1FlexGrid.Columns> <Custom:Column Binding="{Binding ID, Mode=TwoWay}"/> <Custom:Column Binding="{Binding Name, Mode=TwoWay}" Width="*"/> <Custom:Column Binding="{Binding Email, Mode=TwoWay}" Width="*" /> <Custom:Column Binding="{Binding OrderDate, Mode=TwoWay}" Width="*"/> <Custom:Column Binding="{Binding OrderTotal, Mode=TwoWay}" Width="*"/> </Custom:C1FlexGrid.Columns> </Custom:C1FlexGrid> </Grid> |