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

Grid Filters do not reload when filters values reset to defaults

6 Answers 1339 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Graeme
Top achievements
Rank 1
Graeme asked on 04 Apr 2013, 06:36 AM
if you set a column filter value and then click filter in the Grid Column Filter Pop, the grid will filter.

If you then manually set the filtered value back to Nothing ("") by deleting the value in the text box and click filter, nothing will happen, and the grid will still be filtered on the previous value. The expected behaviour woudl be for the Grid to be reloaded with no filters when none are specified and the filter button is clicked.

This is mildly inconsistent when using the standard grid filter functionality, and very broken if you are customising the grid filters yourselves and using dropdowns or multiselects as I am.

In order to fix this behaviour,  the following simple change neds to be made to the filter method of the  FilterMenu object in the lastest source.

 
var FilterMenu = Widget.extend(
.
.
.
 filter: function(expression) {
            expression = this._merge(expression);
            if (expression.filters.length) {
                this.dataSource.filter(expression); 
            } else {                               // Add these lines
                this.dataSource.read();          // Add these lines
            }                                      // Add these lines
        },

Any chance this fix or similar could be incorporated into a future build ?

6 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 05 Apr 2013, 11:59 AM
Hi Graeme,


The default behavior by design is to not perform any action when the filter input field is empty, so the last applied filter remains active. If you want to clear the filters and get the non-filtered data, you could use the "Clear" button. To do it programmatically, you could use the following snippet.
E.g.
var grid = $("#Grid").data("kendoGrid");
grid.dataSource.filter({});

 

All the best,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Graeme
Top achievements
Rank 1
answered on 17 Apr 2013, 07:11 AM
I realise this is the default behaviour. My point is that the default behaviour is not correct.

if a Grid is filtered, using the column filter menu, and then that filter menu item is cleared manually and filter is clicked again (as opposed to using the clear button), then the Grid will not releoad and will still be filtered on the original value even though if you inspect the filter menu visually, or query the datasource filters programmatically, there are no filters.

0
Dimiter Madjarov
Telerik team
answered on 17 Apr 2013, 12:00 PM
Hi Graeme,


If you consider that the implementation of the filters should be changed, please post your suggestion to the Kendo User Voice portal. If it receives enough votes from the community, we will consider to implement it in future releases of Kendo UI.

 

Greetings,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Aliaksandr
Top achievements
Rank 1
answered on 27 Sep 2013, 05:02 PM
Graeme is actually right. The default behavior is inconsistent and needs to be fixed. 

For those who like me wants to customize filter menu and have it functioning properly, you have two options. You can hack source code using Graeme patch above. Or you can hook FilterMenu prototype and overwrite it (with above fix):
kendo.ui.FilterMenu.prototype.filter = function() {
    // expression = this._merge(expression);
    if (expression.filters.length) {
        this.dataSource.filter(expression);
    } else {
        this.dataSource.filter({});
    }
}


0
Anna
Top achievements
Rank 1
answered on 02 May 2016, 10:39 PM

Any new on this issue? I do agree with Graeme and Aliaksandr the filter behavior is inconsistent and broken. It should act at least one of the ways below when filter input box is empty

1. Click "Filter" will reset the filter (function same as Clear Filter button)

2. "Filter" button is disabled when there is no input

3. Click "Filter" will do nothing, but the filter menu will stay open and have error indicator to let user know nothing isn't a valid filter criteria. At very least, if user open the filter menu again, the filter input box should keep the last valid search expression.

 

0
Dimiter Madjarov
Telerik team
answered on 03 May 2016, 07:15 AM

Hello Ama,

As stated previously, the current behavior is by design. If you consider that we should improve it, please post the suggestion in our Feedback portal.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Graeme
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Graeme
Top achievements
Rank 1
Aliaksandr
Top achievements
Rank 1
Anna
Top achievements
Rank 1
Share this question
or