Hi id like to set my own navigation buttons.
I know how to set buttons for differents view, minical.
How to set buttons for: Previous - Today - Next (in client script)
And how could i get the date for setting a label with the current date of the view
Thanks in advance.
Hi,
Check these APIs:
docs.dhtmlx.com/scheduler/api__s … tview.html
docs.dhtmlx.com/scheduler/api__s … state.html
docs.dhtmlx.com/scheduler/api__s … other.html
The date of the calendar can be changed with scheduler.setCurrentView method.
You can retreive currently shown date via scheduler.getState().date
There is built-in helper for date manipulations, that simplifies adjusting dates to any given period
So client side methods might look following:
[code]function previous(){
var currentDate = scheduler.getState().date,
currentMode = scheduler.getState().mode;
var prevDate = scheduler.date.add(currentDate, -1, currentMode);
scheduler.setCurrentView(prevDate)
}
function next(){
var currentDate = scheduler.getState().date,
currentMode = scheduler.getState().mode;
var nextDate = scheduler.date.add(currentDate, 1, currentMode);
scheduler.setCurrentView(nextDate)
}
function today(){
scheduler.setCurrentView(new Date())
}[/code]
Hi, thanks for answering
Id like to know hot to apply locale values to date retrieved with scheduler.getState().date.
For example, i just want to show like in default navigation bar in view month the name of th month and year: i’d like to know how can i get this data through formating current date and then show name of the month in english, how coul i apply formatting and locale values:
im trying in this way
scheduler.getState().date.date_to_str("%F %Y")
but then fires a postback ¿?
Thanks in advance.
date_to_str is a method of scheduler.date object. Date that is returned by scheduler.getState() is a regular JS Date which not have such method.
The method returns function that converts date to string, using labels from scheduler.locale object (by default - English labels).
Usage looks following way:var formatDate = scheduler.date.date_to_str("%F %Y");
var label = formatDate(scheduler.getState().date);
The expected approach to keep relevance of the label is to refresh it on onViewChange event:var formatDate = scheduler.date.date_to_str("%F %Y");
scheduler.attachEvent("onViewChange", function (new_mode , new_date){
var el = document.getElementById(labelElementId);
el.innerHTML = formatDate(new_date);
});
docs.dhtmlx.com/scheduler/api__s … event.html