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

Filter scheduler on 2 parameters

2 Answers 172 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 07 Dec 2016, 09:21 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 09 Dec 2016, 09:03 AM
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.
0
Jonas
Top achievements
Rank 1
answered on 12 Dec 2016, 09:56 AM

Thank you Ivan!

/Jonas

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