Hide group on filter change doesn't work

3 posts, 1 answers
  1. Jonas
    Jonas avatar
    42 posts
    Member since:
    Oct 2014

    Posted 30 Jan Link to this post

    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. Answer
    Peter Milchev
    Admin
    Peter Milchev avatar
    237 posts

    Posted 01 Feb Link to this post

    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.
  3. Jonas
    Jonas avatar
    42 posts
    Member since:
    Oct 2014

    Posted 02 Feb in reply to Peter Milchev Link to this post

    Thank you Peter!

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

     

    BR

    Jonas

Back to Top