Custom Mode Templates

I have 4 custom tabs for my scheduler.

tab A, tab B, & tab C are using the ‘Day’ mode template. However, I want to get tab D to show as a ‘Week’ mode. By default, the scheduler is set to Day mode. Tab D won’t show as a ‘Week’ mode, even if I set tab D’s templates to week.

I followed the example from here: docs.dhtmlx.com/doku.php?id=dhtm … stom_views

Here’s the code for A, B, and C:

[code]// A tab
scheduler.locale.labels.day_tab = “A”;
scheduler.filter_day = function(id, ev) {
if(ev.location != ‘A’) {
return false;
} else if(ev.is_D == ‘true’) {
return false;
}
return true;
}

// B tab
scheduler.locale.labels.B_tab = “B”;
scheduler.filter_B = function(id, ev) {
if(ev.location != ‘B’) {
return false;
} else if(ev.is_D == ‘true’) {
return false;
}
return true;
}

// C tab
scheduler.locale.labels.C_tab = “C”;
scheduler.filter_C = function(id, ev) {
if(ev.location != ‘C’) {
return false;
} else if(ev.is_D == ‘true’) {
return false;
}
return true;
}[/code]

And here’s the code for tab D:

[code]// D tab
scheduler.locale.labels.D_tab = “D”;

scheduler.date.D_start = scheduler.date.week_start;
scheduler.date.get_D_end = function(date) {
return scheduler.date.add(date,1,“week”);
}
scheduler.date.add_D = function(date,inc){
return scheduler.date.add(date,inc*7,“day”);
}

scheduler.templates.D_date = scheduler.templates.week_date;
scheduler.templates.D_scale_date = scheduler.templates.week_scale_date;
scheduler.filter_D = function(id, ev) {
if(ev.is_D == ‘false’) {
return false;
}
return true;
}[/code]

Let me know what I am missing in my code. I only want to render tab D as ‘Week’ mode.

You are using some default templates in your code, so to work correctly, it need to be called only after templates are initialized. Change your code as

[code]scheduler.locale.labels.D_tab = “D”;
scheduler.attachEvent(“onTemplatesReady”, function(){

scheduler.date.D_start = scheduler.date.week_start;
scheduler.date.get_D_end = function(date) {
   return scheduler.date.add(date,1,"week");
}
scheduler.date.add_D = function(date,inc){
   return scheduler.date.add(date,inc*7,"day");
}

scheduler.templates.D_date = scheduler.templates.week_date;
scheduler.templates.D_scale_date = scheduler.templates.week_scale_date;
scheduler.filter_D = function(id, ev) {
   if(ev.is_D == 'false') {
      return false;
   }
   return true;
}

})[/code]

it will execute template related code only after default template initialization

Excellent! that worked for me.

I have another template related question… How can I customize Week Agenda mode? I would like to have 3 different week agendas for three tabs. I’m trying to figure out how to get a custom week agenda to show up.

I included the extension script and I got the default Week Agenda working, but I can’t seem to get the custom one working at all.

This is included within onTemplatesReady event:

[code]// A tab
scheduler.date.A_start = scheduler.date.week_agenda_start;
scheduler.date.get_A_end = function(date) {
return scheduler.date.add(date,6,“day”);
}
scheduler.date.add_A = scheduler.date.add_week_agenda;

scheduler.xy.A_scale_height = scheduler.xy.week_agenda_scale_height;
scheduler.templates.A_event_text = function(start_date, end_date, event, date) {
return scheduler.templates.event_date(start_date) + " " + scheduler.getLabel(“tech_id”, event.tech_id);
};

scheduler.filter_A = function(id, ev) {
if(ev.location != ‘A’) {
return false;
} else if(ev.is_vacation == ‘true’) {
return false;
}
return true;
}[/code]