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

Reducing the number of filter options for multi filter based on filter result

5 Answers 183 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerald
Top achievements
Rank 1
Jerald asked on 25 Sep 2015, 04:32 PM

Is there a way to reduce the number of filter options for a multi filter in Kendo Grid.

Use the dojo below

http://dojo.telerik.com/ANaDi

 Steps to produce output

  1. Click filter menu for contact name
  2. Check off Maria Anders
  3. Apply filter
  4. Click filter menu for contact name again
  5. All filter options show even though they are not visible in the grid itself

Is there a way to narrow down the filter options for each column based on the results after the filter is applied so that zero result filters are not shown inside the filter drop down?

 

Any help is appreciated,

5 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 29 Sep 2015, 09:15 AM
Hi Jim,

Thank you for contacting us.

I follow your steps and my opinion is that the dropdown should work this way. For instance, if you want to filter on some other name what should you do - clear the filter and select the new name with the previously selected? This is possible but imagine if you have 20 name selected and you need to add other one? You have to re-select all 20 name again and also the new one.
The same is correct for the other dropdown filter as well. Another real scenario is that you filter by Maria Anders name and only Sales Representative value is available in Contact Title filter dropdown. But image you need to filter by Owner and Sales Agent. You have to clear the filter of Contact Name and then filter by the title.
Nevertheless, you can check out the following sample which demonstrates how to achieve your requirement. Generally define one DataSource instance and assign it to both the Grid and in columns.filterable.dataSource. This will refresh the checkbox data automatically, and if you filter the Grid data via the Grid UI, you will also filter (reduce) the checkbox items.

I hope this information helps.

Regards,
Kostadin
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jerald
Top achievements
Rank 1
answered on 05 Oct 2015, 02:44 PM

 [quote]Kostadin said:Hi Jim,

Thank you for contacting us.

I follow your steps and my opinion is that the dropdown should work this way. For instance, if you want to filter on some other name what should you do - clear the filter and select the new name with the previously selected? This is possible but imagine if you have 20 name selected and you need to add other one? You have to re-select all 20 name again and also the new one.
The same is correct for the other dropdown filter as well. Another real scenario is that you filter by Maria Anders name and only Sales Representative value is available in Contact Title filter dropdown. But image you need to filter by Owner and Sales Agent. You have to clear the filter of Contact Name and then filter by the title.
Nevertheless, you can check out the following sample which demonstrates how to achieve your requirement. Generally define one DataSource instance and assign it to both the Grid and in columns.filterable.dataSource. This will refresh the checkbox data automatically, and if you filter the Grid data via the Grid UI, you will also filter (reduce) the checkbox items.

I hope this information helps.

Regards,
Kostadin
Telerik

 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
[/quote]

Hi Kostadin, 

That works but there is an issue I am running into. It is only showing filters for the current view of the grid contents instead of all the data in the grid which results in duplicate filter entries.

For example in the dojo you posted in the Product Name field there is only the pageSize amount of options to filter on in this case 20. Also since the page size contains x amount 29's and 39's in Units in Stock field they show up x amount of times in the filter menu.

An example towards the application I am currently working on. The grid contains multiple states x amount of times, ​if I were to filter on Alabama, it will bring up 22 Alabama entries and the State filter will now show 22 Alabama entries instead of just one. If I were to filter on more abstract data and 22 Alabama and 14 Kansas entries showed up and my page size is 10 it will show only 10 entries in the filter drop down with x amount of Alabama, y amount of Kansas entries in the grid view.

The implementation of the filter that I am looking for is to be able to have a unique and dynamic multi list of filters based on the grids data as a whole where it scales the options appropriately towards only valid filters in the current grids data. 

Thank you for your help

 

0
Kostadin
Telerik team
answered on 07 Oct 2015, 09:03 AM
Hello Jim,

Indeed the logic for finding and displaying the distinct(unique) values will not be executed in case of using same DataSource instance for the Kendo UI Grid and multi filter check box. 

I would suggest to use the following approach in order to refresh the multi checkbox filter options:

$(".k-grid-filter").click(function(e){
                    var fmc = $(e.target).closest("th").data("kendoFilterMultiCheck");
                    fmc.checkSource.read();
                    fmc.container.empty();
                    fmc.refresh();
                  });

Please refer to the http://dojo.telerik.com/oKerE/19 example. 

Regards,
Kostadin
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jerald
Top achievements
Rank 1
answered on 15 Oct 2015, 03:26 PM
[quote]Kostadin said:Hello Jim,

Indeed the logic for finding and displaying the distinct(unique) values will not be executed in case of using same DataSource instance for the Kendo UI Grid and multi filter check box. 

I would suggest to use the following approach in order to refresh the multi checkbox filter options:

$(".k-grid-filter").click(function(e){
                    var fmc = $(e.target).closest("th").data("kendoFilterMultiCheck");
                    fmc.checkSource.read();
                    fmc.container.empty();
                    fmc.refresh();
                  });

Please refer to the http://dojo.telerik.com/oKerE/19 example. 

Regards,
Kostadin
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 

[/quote]

 I understand the concept behind what that approach is attempting to accomplish but in the dojo it is unfortunately not removing the Two and Three options from the filter menu if I select One as the option I want to filter on.

Thanks for the help.

0
Kostadin
Telerik team
answered on 19 Oct 2015, 10:39 AM
Hi Jim,

I am afraid there isn't another approach to achieve your requirement. Theoretical you can use the previously provided approach and set different datasource to the check list filtering and not the one which uses the grid. Nevertheless you need to filter it manually and also remove the duplicating records.

Regards,
Kostadin
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
Jerald
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Jerald
Top achievements
Rank 1
Share this question
or