This is a migrated thread and some comments may be shown as answers.

Bug where Grids filter without input

3 Answers 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
IT Dept
Top achievements
Rank 1
IT Dept asked on 22 Jul 2019, 06:43 PM

There is an annoying bug in the Kendo React Grid filters. If you open the filter menu and select a filter type without supplying a value, it still sends the request for data to the backend using that filter. But the ASP.NET MVC kendo ToDataSourceResult can't handle this as the `value` is `null`, because the filter input is empty. Worse, it throws an exception on the backend request and the grid empties itself as the response had no rows in it.

Is there an accepted way to work around this, preventing it from making requests when no filter value has yet been entered? I'm trying to avoid having to write a handler on our controller methods that will strip filters that have Value of `null`, expecially since the interface of the Filter collection on the dataSourceRequest doesn't explicitly state there will be a value property.

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 Jul 2019, 09:30 AM
Hello, Eric,

I can suggest this to be handled in the onDataStateChange or onFilterChange(whichever one is used). The Grid will only emits the event based on the user interaction, and then a request is made programmatically based on the data. We send the information as it is, as the Grid can be connected with many different back-end services and in some of them, this could be a valid parameter that for example will return all of the data.

For example, on the used event a check can be made if there a filter parameter with no value, and handle it based on the application business logic, either removing the filter from the collection, or returning all of the data as there is not filter that has to be matched. Then make the request with the modified filters.

Please let me know if more details are needed on this matter.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
IT Dept
Top achievements
Rank 1
answered on 23 Jul 2019, 03:51 PM

Hi Stefan,

I added some logic to remove the valueless filters in the onDataStateChange handler, but my suspicions about the issues this would cause were correct: If you throw out that filter rule, you also lose what was configured so far in the filter. ie., if a user clicks the filter and sets it to "Is Greater Than" but hasn't entered a value yet, throwing that out in onDataStateChange throws out the "Is Greater Than" selection. When they enter a value next it will be using the default (for numerical, Is Equal). This is less janky than the previous behavior (picking Is Greater Than leading to the data request failing on a comparison to null, and the grid becoming empty), but it is still not ideal.

Eric

0
Stefan
Telerik team
answered on 24 Jul 2019, 11:02 AM
Hello, Eric,

In this case, instead of removing the filter entirely, I can suggest only modifying its value, so the server will not throw an error and the returned data will be as expected.

This may require a change in the server as well, to properly handle empty values, which can be an empty string. For example, if the filter on empty string this will return all values or something else based on the application logic.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
IT Dept
Top achievements
Rank 1
Answers by
Stefan
Telerik team
IT Dept
Top achievements
Rank 1
Share this question
or