asynct Task ContextMenuClick(ContextMenuItem) {
var state = Grid.GetState(); state.FilterDescriptors.Add(new FilterDescriptor { Member = "Created", Operator = FilterOperator.IsEqualTo, Value = "Administrator" }); await Grid.SetState(state);
}
How it should look like:
Hi Liero,
The grid state is a collection of objects. The way the grid works with these objects is documented and it is up to you to manage those collection to use and achieve the different behaviors that are possible. We have even provided some sample extensions methods, and you are free to write your own in order to do what you want to do. We can't anticipate every application need and write methods for it, manipulating collections and data is something the application should be able to do.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Liero,
I made a sample for you that mimics this setup and seems to work fine for me so you can compare against it. It is attached to the end of this post. I'm also attaching a short video of the expected behavior.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Martin,
although I managed to set the filter menu from code, I still don't get the filter icon highlighted:
Hello Daniel,
The grid has default filters and so adding some filters like that is not going to affect the UI - the grid uses the first filter, and that's the default one, to affect the UI. You need to either new up the entire filters collection, or to replace the current filter with the new one you want to build.
I've updated the documentation to explain this (PR link with the diff) and you can find that sample live here (it is the second snippet, but I also advise you review the first one for the correct types): https://docs.telerik.com/blazor-ui/components/grid/filter/filter-menu#filter-from-code.
On another note - you need to make sure to use the correct type of filter and to set its member type as well, see the examples above for that.
With that said, I am marking this as "Declined" because it is not a bug in the component, but expected behavior that I had not documented. It is now documented and you can use the sample as base for further development.
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.