Setting the FilterDirector directly:
Setting FilterDescriptor via SearchText:
Our search box is a custom TelerikTextbox not part of the grid, but essentially the same functionality as the built-in search box.
To test, use this code:
https://docs.telerik.com/blazor-ui/components/grid/filter/searchbox#customize-the-searchbox
But add it to FilterDescriptor immediately rather than setting SearchFilter like on the link.
This is the only instance of this on our site, and all of our grids use the exact same code via a generic method, on our object that controls the grid we have a custom empty attribute to dictate whether a column should be filterable via our textbox.
Hello Benjamin,
OK, if you want to show the search string in the FilterMenu and this leads to repetitive textboxes, this means that the filter descriptor structure is wrong. For example, GridState.FilterDescriptors has a single parent descriptor, while it should have multiple ones - one for each filtered Field (Member). However, if you do this, the Grid will stop showing data, because the component applies all filter descriptors at root level with an AND logical operator, while you need OR.
So, my advice is to show the search string somewhere outside the FilterMenu and use the SearchFilter property of the Grid state.
Regards,
Dimo
Progress Telerik
Hi Dimo,
That is exactly as I said.
We are making use of the Search Text now yes but we wanted to have it show up in the FilterMenu's text field which as we see is the FilterDecriptor, which caused a bug on the grid showing a bunch of duplicated filters.
Regards,
Hello Benjamin,
It looks like your app is adding FilterDescriptors to the Filter state. Instead, it should add descriptors to the Search state.
Note this code in our example. If you enable the FilterMenu for it, it will still work.
GridState<SampleData> desiredState = new GridState<SampleData>()
{
SearchFilter = CreateSearchFilter()
};
await Grid.SetStateAsync(desiredState);Regards,
Dimo
Progress Telerik