Units view multiple filters

Is there anyway to apply multiple filters for the units view, for example I have this:

scheduler.createUnitsView({
    name:"unit",
    property:"unit_id", 
    list:[             
        {key:1, label:"Section A"},
        {key:2, label:"Section B"},
        {key:3, label:"Section C"},
        {key:4, label:"Open"},
        {key:5, label:"Closed"}  

    ]
});
 
scheduler.init('scheduler_here');
scheduler.parse([
    {id:1, text:"Task1", start_date:"2019-09-17 12:00", end_date:"2019-09-18 21:00", 
    unit_id:"1", "unit_state: "4"},
    {id:2, text:"Task2", start_date:"2019-09-17 09:00", end_date:"2019-09-17 21:00", 
    unit_id:"3", "unit_state: "4"},
    {id:3, text:"Task3", start_date:"2019-09-17 15:00", end_date:"2019-09-18 15:00", 
    unit_id:"2", "unit_state: "5"}
]);

So for example I filter based on the section and the state I should get:

Section A and Open: Task1
Section B and Closed: Task3
Section C and Open: Task 2

Thanks!

Hello @Javiera_Meneses ,

If you want to display or not display some units, the easiest way is to recreate the units view with a new config:

...
function filterSectionC(){
	scheduler.createUnitsView({
    name:"unit",
    property:"unit_id", 
    list:[             
        {key:3, label:"Section C"}, 
    ]
});
}
function filterSectionBC(){
  scheduler.createUnitsView({
    name:"unit",
    property:"unit_id", 
    list:[             
      {key:2, label:"Section B"},
      {key:3, label:"Section C"}, 
    ]
  });
}

Here is the live demo(Click C, BC, All buttons to check):
http://snippet.dhtmlx.com/5/ed5bc91c0

If you meant something different, could you please clarify the required scenario?

1 Like

Thanks for your answer!

I actually meant to group the events using more than one key. For example grouping by section and color. I ended up creating a new key for those events that apply for both filters.