Custom filtering combined with built-in search and filtering

1 Answer 21 Views
Grid
I3next
Top achievements
Rank 1
I3next asked on 12 Apr 2024, 08:30 AM
Good morning,
 
I’m attempting to implement a ASP.NET MVC grid with custom filter functionality that’s integrated with my grid filters. However, I’m struggling with filter values getting overwritten when performing search filter functionality.
 
In my grid I have inline grid row filtering:
                          .Filterable(filterable => filterable
                               .Extra(false)
                              .Operators(operators => operators
                                  .ForString(str => str.Clear()
                                      .IsEqualTo("Is equal to")
                                      .IsNotEqualTo("Is not equal to")
                                      .StartsWith("Starts with")
                                      .Contains("Contains")
                                      .DoesNotContain("Does not contain")
                                      .EndsWith("Ends with")
                                      .IsNull("Is null")
                                      .IsNotNull("Is not null")
                                      .IsEmpty("Is empty")
                                      .IsNotEmpty("Is not empty")
                               ))
                           )
I also make use of inline grid search as filtering. This search functionality is defined in my grid toolbar:
                       toolbar.Search();
Lastly, for my mentioned custom filter functionality, I have defined two multiselects in my grid toolbar. These multiselects make use of a JavaScript onchange event that gets fired upon changing the multiselect value. This JavaScript function calls grid.dataSource.filter() to apply the filtering and then automatically call the grid read event. The set-up for this code is comparable to the example for the grid toolbar template: https://demos.telerik.com/aspnet-mvc/grid/toolbar-template
To retrieve my results, I make use of a datasource with .webApi() configuration, making use of a controller method that gets called with my read event. This controller method contains a DataSourceRequest that contains the set filters. The problem I’m facing is that when I input text into my search filter, that the set multiselects filters get overwritten.
Is there a way I can perform search and column filter functionality without it overwriting my multiselect filters?
ASP.NET MVC Grid Toolbar Template Demo | Telerik UI for ASP.NET MVC
This Telerik ASP.NET MVC Grid example shows how you can add custom toolbars to the grid and create toolbar templates.

https://demos.telerik.com/aspnet-mvc/grid/toolbar-template
Patrick
Top achievements
Rank 1
commented on 15 Apr 2024, 05:59 PM

My problem is that my Grid was working Friday April 12, 2024, and now the Filter it's causing my grid to error out. If I remove the Filter, my Grid works fine.

                .Filterable(filterable => filterable
                .Extra(false)
                .Operators(operators => operators
                    .ForString(str => str.Clear()
                        .Contains("Contains")
                    ))
                )

Error:

Could not load file or assembly 'Telerik.FontIcons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20b4b0547069c4f8' or one of its dependencies. The system cannot find the file specified.

 

Ivan Danchev
Telerik team
commented on 17 Apr 2024, 06:58 AM

The error about the Telerik.FontIcons assembly is due to the introduction of the svg icons in the R1 2023 release. In R1 2023 (2023.1.314) and later versions of the product, two NuGet packages must be installed: Telerik.FontIcons and Telerik.SvgIcons

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 17 Apr 2024, 06:56 AM

Hello,

When you filter the Grid, its is rebound with the filtered data and it is also re-rendered. Consider saving the MultiSelect value in a variable. Then, after filtering is done and the Grid re-renders and visualizes the filtered data, you can get the previously saved value from the variable in the Grid's dataBound event handler and set the MultiSelect value (see the value() API method of the MultiSelect: https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect/methods/value).

Regards,
Ivan Danchev
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.

Tags
Grid
Asked by
I3next
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or