Double click on a tab to get the correct dataset?

I just have a minor problem right now. When I click on a tab and it renders the proper view, but all events (including the ones that are supposed to be filtered out) are displayed by default… It doesn’t filter for the events I wanted to be displayed. However, when I click on the same tab again, only the filtered events are displayed.

I tried it many different ways, but with same results. Any idea what kind of fix I need for this issue?

Here’s a sample of my code:

scheduler.attachEvent("onViewChange", function(mode, date){ if(mode=="AM") { scheduler.setCurrentView(date,"month"); scheduler.filter_month = function(id, ev){ if(ev.location != 'A') { return false; } else if(ev.is_vacation == 'true') { return false; } return true; } } else if(mode=="AW") { scheduler.setCurrentView(date,"week_agenda"); scheduler.filter_week_agenda = function(id, ev) { if(ev.location != 'A') { return false; } else if(ev.is_vacation == 'true') { return false; } return true; } } else if(mode=="AD") { scheduler.setCurrentView(date,"agenda"); scheduler.config.agenda_start = new Date(date); scheduler.filter_day = function(id, ev) { if(ev.location != 'A') { return false; } else if(ev.is_vacation == 'true') { return false; } return true; } ... } }

Hello,

You should define filter function before you change the view with setCurrentView.

Kind regards,
Ilya

Hello Ilya,

thanks for your prompt reply. I changed the code as per your instruction, but it still doesn’t work.

If I change the current view after defining the filter function, the events won’t show up at all and the current view is stuck at whichever view I was using before clicking on a new tab.

For your review, I modified the code like this:

scheduler.attachEvent("onViewChange", function(mode, date){ if(mode=="AM") { scheduler.filter_month = function(id, ev){ if(ev.location != 'A') { return false; } else if(ev.is_vacation == 'true') { return false; } scheduler.setCurrentView(date,"month"); // Where I made the change. return true; } ...

Please disregard my previous post. I found out my error and fixed it.

Here is the code I used to get it working:

scheduler.attachEvent("onViewChange", function(mode, date){ if(mode=="AM") { scheduler.filter_month = function(id, ev){ if(ev.location != 'A') { return false; } else if(ev.is_vacation == 'true') { return false; } return true; } scheduler.setCurrentView(date,"month"); // The right place for this line. }

Thanks Ilya!