Get Visible Items in RadGridView When Full Text Search and Search Filtering is Disabled
Environment
Product | RadGridView for WPF |
Version | 2023.2.718 |
Description
How to access the search results (row data items) in RadGridView, when search as you type is executed and the IsSearchFilteringEnabled
setting is False.
Solution
You can create a new SearchFilterDescriptor
object and use it in a new QueryableCollectionView instance. This will allow you to manually filter the original data collection and get the needed results.
var searchPanel = this.gridView.FindChildByType<GridViewSearchPanel>();
if (searchPanel != null)
{
var dataMembers = this.gridView.Columns.OfType<GridViewBoundColumnBase>()
.Select(col => SearchDataMemberDescriptor.FromColumn(col))
.OfType<SearchDataMemberDescriptor>()
.ToList();
var descriptor = new SearchFilterDescriptor(dataMembers, FilterOperatorType.Positive, this.gridView.SearchStateManager);
descriptor.FilterValue = ((SearchViewModel)searchPanel.DataContext).SearchText;
var qcv = new QueryableCollectionView((IEnumerable)this.gridView.ItemsSource);
qcv.FilterDescriptors.Add(descriptor);
var foundItems = qcv.OfType<MyRowItemInfo>();
}