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

Hide group on filter change doesn't work

2 Answers 63 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 30 Jan 2017, 09:26 AM

Hello

I have a scheduler that I'm grouping on a resource; rooms. When I filter the scheduler on rooms, I want to hide the groups of rooms that are not selected in the filter.
I have looked at this example, but I don't get it to work. The filering part works as intended, but not the hiding of the filtered rooms. I will post, what I think is all relevant parts of my code. If you need more info please ask me to provide it. (IE Alex, Bob and Charlie from the link are the corresponding entities to my rooms)

First, the grouping and resource binding part of the scheduler:

.Group(group => { group.Resources("Room"); })
    .Resources(resource => resource.Add(m => m.roomId)
        .Title("Room")
        .Name("Room")
        .DataTextField("name")
        .DataValueField("id")
        .DataColorField("Color")
        .DataSource(ds => ds.Read("GetRooms", "Home")))

 

Then the function for viewing only selected rooms:

function viewRoom() {
        var checked = $.map($("#factories :checked"), function (dropdown) {
            return parseInt($(dropdown).val());
        });
        var filter = {
            logic: "or",
            filters: $.map(checked, function (value) {
                return {
                    operator: "eq",
                    field: "roomId",
                    value: value
                };
            })
        };
        var scheduler = $("#scheduler").data("kendoScheduler");
        scheduler.dataSource.filter(filter);
 
        scheduler.view(scheduler.view().name);
    }

 

From what I understand this row should update the view with only the selected rooms visibible in the scheduler, but it doesn't:

scheduler.view(scheduler.view().name);

 

Can anyone see what I'm doing wrong?

BR
Jonas

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 01 Feb 2017, 09:03 AM
Hello Jonas,

Here is a Dojo example that implements the room filtering. Would you please check if modifying the filter field and the dataSource that the filter is applied to solves the issue? 

var filter = {
         logic: "or",
         filters: $.map(checked, function(value) {
           return {
             operator: "eq",
             field: "value",
             value: value
           };
         })
       };
 
       var scheduler = $("#scheduler").data("kendoScheduler"); 
       //filter the resource data source
       scheduler.resources[0].dataSource.filter(filter);


Regards,
Peter Milchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jonas
Top achievements
Rank 1
answered on 02 Feb 2017, 03:28 PM

Thank you Peter!

It was a mismatch between the filter field and the DataValueField in the Resource

 

BR

Jonas

Tags
Scheduler
Asked by
Jonas
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Jonas
Top achievements
Rank 1
Share this question
or