This is a migrated thread and some comments may be shown as answers.
kendoFilterMultiCheck - trigger refresh when datasource is modified
6 Answers 18 Views
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 11 Dec 2020, 12:30 PM

I would really like to know how one can go about causing the multi select filter items in the kendoFilterMultiCheck dropdown list to refresh when the list is opened up after the datasource has been read again. I've had a look at the suggestions here:

https://www.telerik.com/forums/refresh-multi-checkbox-filter-options-when-grid-is-filtered

However, I don't want to use the serDataSource method because that triggers a re-rendering of the grid.

I don't want to create data sources for each colum that needs to be filtered as this is going to be too heavy on processing.

I don't want to use a data source and assign it to both the grid and the filterable data source as it alters the list of items in the dropdown when filtering is applied

There's a behavior that I was hoping to mimic programatically and that is the following:

The dropdown list is rendered correctly the first time it is clicked based on the state of the underlying grid's data source. If you've rendered the grid 5 times changing the datasource each time and then only click on the filter menu item, the list shows the latest data source's valid values.

If I re-read the datasource, how can I set the state of the filter item so that it is seen as the first time it is opened again?

I would really appreciate some help with this.

 

 

 

 

 

 

6 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 15 Dec 2020, 08:50 AM

Hi Matthew,

Thank you for the provided details on the scenario you are willing to achieve. Indeed, the options outlined in the referred are the recommended ones. This is due to the fact that the "checkSource" is built only once - when the grid is created. The setDataSource method of the grid rerenders it, causing the "checkSource" to be created once again with the currently available data set.

 

Best regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Matthew
Top achievements
Rank 1
answered on 21 Dec 2020, 09:07 AM

Hi Tsvetomir, thank you very much for the response. Is it definitely when the grid is created? I've found that the data that is within the grid at the time the column header is clicked on is used to generate the list of items. So if you update the datasource again via the read method after the grid is created, the items at that point in time are used. So it seems to be when the grid header is clicked for the first time and not when the grid is rendered. But after that, subsequent calls to the read method have no influence on the filter items. Is there anyway I can replicate that method within the code? I've tried to remove the checkSource via js code but that just clears the list and then there are no items available in the filter. I'm really hoping to be able to repopulate that list as efficiently as it is when its created that first time but if that's not possible that's fine, I'm just hoping that there might be a way I can replicate that behavior programatically. Thanks very much.

 

 

 

 

0
Matthew
Top achievements
Rank 1
answered on 21 Dec 2020, 01:16 PM

Hi Tsvetomir, I'm not sure if this approach is a bit primitive but I found the code in the kendo.all.min.js file that is responsible for creating the initial list of filter values. It's in the _init event of the "kendoFilterMultiCheck" object it seems. What I've done is call that even again when the dataBound event of the grid fires. This is a sample of what I'm doing:

 

var arr = $('.k-filterable');
if (arr != null) {
    for (i = 0; i < arr.length; i++) {
        var fmc = $($('.k-filterable')[i]).data("kendoFilterMultiCheck");
         
        if (fmc != null) {
            fmc._init();
        }
    }
}

 

This works and achieves what I need it to do. Does this look like a suitable approach to you according to what I'm trying to achieve and considering what approaches I'm trying to avoid.

 

 

 

Thanks very much.

0
Accepted
Tsvetomir
Telerik team
answered on 22 Dec 2020, 01:09 PM

Hi Matt,

It is correct that the values for the menu are built within the "init" of the FilterMultiCheck object. And explicitly calling it, you would achieve the desired functionality.

However, what I can recommend is that you actually do extensive testing on the scenario. This is due to the fact that the init() method triggers other methods and doing this every time the DataBound event is triggered, you might experience a negative impact on the performance of your application.

Note that such modifications are not officially supported. However, after testing it out, you might stick to this code snippet with no issues.

 

Best regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Matthew
Top achievements
Rank 1
answered on 23 Dec 2020, 06:52 AM

Hi Tsvetomir,

Thanks so much for the response. We've put the change into testing and I've also done what I can to try find any problems with the solution but so far it seems fine.

Thanks again for your assistance, much appreciated!!

Kind regards,

Matthew

 

 

0
Tsvetomir
Telerik team
answered on 23 Dec 2020, 04:00 PM

Hi Matthew,

I am glad to hear that the implementation has passed the tests on your side. If there is anything else that I can help with, do not hesitate to contact me back.

 

Kind regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Matthew
Top achievements
Rank 1
Share this question
or