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

filter items list not updated when datasource is read again

1 Answer 304 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dakota
Top achievements
Rank 1
Dakota asked on 23 Nov 2016, 07:52 PM

I'm using angular. In my column field, i have:

                        filterable: {
                            ui: function (element) {
                                $scope.multiSelectFilter(element, "weekdays")
                            }
                        }

This is making use of "currying" technique I believe. In the multiSelectFilter function, I determine the distinct list of values for this column based on the datasource, and push them into the ddataSource.filter() options. This produces the correct distinct values for the multiSelect dropdown in the filter area.

When a new dataSource.read() takes place, in my case because a new HTTP call is being made, the new results populate the grid as expected.

The issue is that the column filterable (above code) is not re-run with the new data, so the filter drop-down doesn't reflect the new datasource data. I did read that this is intentional, only running n the initial grid load to be more efficient.

EXAMPLE: Let's say my table I'm hitting the http call for is a table of all of my events on my calendar. LEt's say the initial call passes in an argument to the request for only events labeled "birthdays". Let's say we get 3 results - one on Monday, one on Tuesday, one Wednesday. Cool beans. Now I make an additional call to my service that returns all of my events of all kinds - resulting on having events on every day of the week at some point or another. I go to the weekdays dropdown, and only >monday,tuesday,wednesday" options are displayed. This is my problem.\

I'd prefer not to have to destroy and then recreate the grid just for the sake of reapplying the drop-down filters correctly. I've played around with filterMenuInit, but the problem I'm having is that I still need to pass the specific field name like I am above - and now just for this one column, but for multiple, and I don't think I can access the element's field name in the filterMenuInit without potentially using Jquery.

My other thought was trying to use the change: event but ran into the same issue.

Looking for the most efficient solution (not involving Jquery).

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 25 Nov 2016, 09:08 AM

Hello Dakota,

In order to achieve such functionality you will need to manually refresh the filter widget's data when the new Grid data is fetched. Here you can find a basic implementation of such approach. It is using a very primitive notification implementation in order to re-populate the filter widget.

Regards,
Rosen
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Dakota
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or