Filter scheduler on 2 parameters

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

    Posted 07 Dec 2016 Link to this post

    Hello

     

    I have a scheduler that I want to filter on 2 different parameters (Team and Factory). With my current implementation I am only able to filter on one of the two. I have a dropdown for the teams and checkbuttons for the factories. So the aim is that you should be able to look at one or all teams AND 1 to all factories. How can I achive this filter?

    This is what I got so far:

    .Filter(filters =>
       {
         filters.Add(model => model.teamId).IsEqualTo(4).Or().IsEqualTo(5).Or().IsEqualTo(6);
         filters.Add(model => model.factoryId).IsEqualTo(1).Or().IsEqualTo(2).Or().IsEqualTo(3);
        })

    Do I even really need this if I want to show everything default on load?

    $("#teamDDL").change(function (e) {
            var checked = $.map($("#teamDDL"), function (dropdown) {
                return parseInt($(dropdown).val());
            });
            if (checked == "NaN")
                checked = [4, 5, 6];
            var filter = {
                logic: "or",
                filters: $.map(checked, function (value) {
                    return {
                        operator: "eq",
                        field: "teamId",
                        value: value
                    };
                })
            };
            var scheduler = $("#scheduler").data("kendoScheduler");
            scheduler.dataSource.filter(filter);
        });
     
    $("#factories :checkbox").change(function (e) {
            var checked = $.map($("#factories :checked"), function (dropdown) {
                return parseInt($(dropdown).val());
            });
            var filter = {
                logic: "or",
                filters: $.map(checked, function (value) {
                    return {
                        operator: "eq",
                        field: "factoryId",
                        value: value
                    };
                })
            };
            var scheduler = $("#scheduler").data("kendoScheduler");
            scheduler.dataSource.filter(filter);
            scheduler.view(scheduler.view().name);
        });

     

    So I have 2 functions for updating the filters, one for the dropdown and one for the checkboxes. I need to modify these two functions to do an AND search on both the dropdown value and the checkbox values, how do I do that?

     

    BR
    Jonas

  2. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    1304 posts

    Posted 09 Dec 2016 Link to this post

    Hello Jonas,

    A filter is set to the Scheduler's dataSource and this is a functionality of the Kendo UI DataSource, i.e. it is not specific to the Scheduler widget or wrapper. You can find similar scenarios of creating complex filters discussed in the following threads: stackoverflow, telerik forums. I hope they point you in the right direction with regard to implementing the desired filter.

    Regards,
    Ivan Danchev
    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
  3. Jonas
    Jonas avatar
    42 posts
    Member since:
    Oct 2014

    Posted 12 Dec 2016 in reply to Ivan Danchev Link to this post

    Thank you Ivan!

    /Jonas

Back to Top