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
- Click filter menu for contact name
- Check off Maria Anders
- Apply filter
- Click filter menu for contact name again
- 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
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

[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
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
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

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
[/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.
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