我有以下http://snippet.dhtmlx.com/5/314bf7ab3,但我有日历的一天,我也想把如果它是星期一,星期二等…
在https://docs.dhtmlx.com/scheduler/timeline_view.html#daysmodedetails的文档中,他们应该有一天,但我从来没有设法输出值。
谁能帮我一下?由于问题似乎出在刻度标签模板定义上。
TLDR:一旦你像下面这样重命名模板,它应该可以工作了:
var dateToStr = scheduler.date.date_to_str("%j %F, %l");
scheduler.templates["timeline_scale_label"] = function(section_id, section_label, section_options){
return dateToStr(section_label);
};
现在你有这样的声明:
var dateToStr = scheduler.date.date_to_str("%j %F, %l");
scheduler.templates["weektimeline_scale_label"] = function(section_id, section_label, section_options){
return dateToStr(section_label);
};
模板名称为weektimeline_scale_label。但是时间轴视图是在timeline下声明的名称:
scheduler.createTimelineView({
...
name:"timeline",
...
});
模板必须包含时间线视图的名称(因为调度程序允许创建多个时间线),即**调度程序。模板[${timeline.name}_scale_label
].
在这里,模板应该命名为timeline_scale_label:
var dateToStr = scheduler.date.date_to_str("%j %F, %l");
scheduler.templates["timeline_scale_label"] = function(section_id, section_label, section_options){
return dateToStr(section_label);
};
或
var dateToStr = scheduler.date.date_to_str("%j %F, %l");
scheduler.templates.timeline_scale_label = function(section_id, section_label, section_options){
return dateToStr(section_label);
};
片段:https://snippet.dhtmlx.com/5/7ef709780
还要注意,日期时间轴视图不支持标记(scheduler.addMarkedTimespan),但您可以使用scheduler.templates.timeline_cell_class
模板为单元格上色:
scheduler.templates.timeline_cell_class = function(evs, date, section){
const cellDateValue = section.key;// day-timeline cells receive date values in section.key
if(cellDateValue >= new Date(2019,11,20) && cellDateValue < new Date(2019,11,21)){
return "blue_section";
}
return "";
};
下面是一个演示:https://snippet.dhtmlx.com/sxorcz6s