Change scheduler date without retrieving events

Hi,

I’ve a Scheduler with a 1) dropdown to select certain type of events of the server and a 2) date filter. The scheduler is configured to setLoadMode(“month”) to fetch events dynamically when moving backward and forward.

When I select a different dropdown filter I need to fetch events from the database. I do it by:

scheduler.setCurrentView(date_filter);
scheduler.load("url/get_events/"+dropdown_filter,  function(){
   some_javascript_functions();
});
if (not_first_data_load) scheduler.clearAll();

I need to setCurrentView because I need to move calendar to the desired date selected by the date filter. But it doesn’t work in some cases:
[b]WHEN I select a dropdown filter and a date filter with a different month than the actual, Scheduler makes a duplicate get_events call to the server: one because setCurrentView detect that current scheduler doesn’t have the events loaded in the selected month, and another one because scheduler.load needs to get new events with the different dropdown filter.

I need setCurrentView can point the scheduler to an specified date without getting new data from server.[/b]

I tried something like that but it don’t work:

scheduler.setLoadMode(false);
scheduler.setCurrentView(data_inici);
scheduler.setLoadMode("month");

Any suggestion?

Thx

Hi,
if I understand correctly, the issue is following:

  1. you use dynamic loading which caches previously loaded events so it won’t call ajax for already visited dates.
  2. when you apply some filter (whether it shows type of events or events from a certain date), you need to clear previously loaded events and change data loading url before loading new portion of data

It may be a bit tricky with the built in dynamic loading and may require usage of private api in order to change dynamic loading url.
Probably it may be simpler if you remove scheduler.setLoadMode call and do dynamic loading manually from onBeforeViewChange handler:

[code]scheduler.attachEvent(“onBeforeViewChange”, function (old_mode, old_date, mode, date){
scheduler.clearAll();//clear previously loaded events

//load events for new date range
//and the current filter

var from = scheduler.date[mode + "_start"](new Date(date));
var to = scheduler.date.add(from, 1, mode);

if(mode == "month"){// month date range start from the start of the week, which may be earlier than 1st of the month
    from = scheduler.date.week_start(from);
    to = scheduler.date.week_start(scheduler.date.add(to, 1, "week"));
}

var dateToStr = scheduler.date.date_to_str(scheduler.config.api_date);

var params = ["from="+dateToStr(from), "to=" + dateToStr(to)];

//'dropdown_filter' should be available here, or you can get value from dropdown dom element
scheduler.load("url/get_events/"+dropdown_filter + "?" + params.join("&"),  function(){
   some_javascript_functions();
});

});
[/code]
It should load a new portion of data each time you scroll dates in calendar, so you can remove ‘scheduler.setLoadMode’ call.
When you select different type of events from dropdown, you can simply refresh scheduler by calling setCurrentView without arguments and onBeforeViewChange handler should do:

scheduler.setCurrentView();

and the same goes for the date filter, it should load correct dataset when you change calendar date:

scheduler.setCurrentView(newDate);