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

Problem removing filter

3 Answers 426 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Dany
Top achievements
Rank 1
Dany asked on 06 Dec 2017, 03:27 PM

Hi, I have a problem removing filter when i remove on filter item or all items with "X", my multiselect keep filtering and i don't have all my original datasource data. Here's my definition of my multiselect control :

 

 $("#searchFilter").kendoMultiSelect({
            placeholder: "Catégories de biens et services...",
            filter : "contains",
            dataTextField: "Name",
            dataValueField: "ServiceID",
            height: 400,
            dataSource: {
                data: @(New HtmlString(Json.Encode(Model.ServicesFilter))),
                group: { field: "ParentBreadcrumb" },
                },           
            change: function(){
                PMEL_SupplierSearch.triggerSearch();
            },




            filtering: function(ev){
                if(ev.filter) {     
                    var filterValue = ev.filter.value;                    
                    ev.preventDefault();
                    this.dataSource.filter({
                        logic: "or",
                        filters: [
                          {
                              field: "Name",
                              operator: "contains",
                              value: filterValue
                          },
                          {
                              field: "Keywords",
                              operator: "contains",
                              value: filterValue
                          }
                        ]
                    });
                    }                    
                }
            }


        });

3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 08 Dec 2017, 08:10 AM
Hello Dany,

Since the filter method accepts an array, you can clear the dataSource filters by passing an empty array, Please consider the below implementation and dojo example:

var ms = $("#multiselect").data('kendoMultiSelect');
    ms.dataSource.filter([])

https://dojo.telerik.com/adEpa/7

Regards,
Nencho
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dany
Top achievements
Rank 1
answered on 08 Dec 2017, 12:55 PM
This work well if i remove filter with Remove all (x) but if i have only one filter and remove it with his X, this don't work. Also If i remove filter with bacspace this don't work.
0
Nencho
Telerik team
answered on 12 Dec 2017, 10:58 AM
Hello Dany,

In order to have the filters properly cleared, you should clear them as previously demonstrated, on the select event of the MultiSelect. Hence, you will ensure that the filter is nullified each time a selection is performed. IN addition, you can clear it if the filtering event, when the filter.value is empty. 

In the following dojo example, you can observe implemented the above suggested approach:

http://dojo.telerik.com/@nenchef/amiFU

Regards,
Nencho
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
MultiSelect
Asked by
Dany
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Dany
Top achievements
Rank 1
Share this question
or