dhtmlx-scheduler

Having what week day is on left column


I have the following http://snippet.dhtmlx.com/5/314bf7ab3 but where i have the day of the calendar, i also want to put if it's monday, tuesday or so on...

In the documentation at https://docs.dhtmlx.com/scheduler/timeline_view.html#daysmodedetails they should have the day but i never manage to output the value.

Can someone give me a hand? Thanks


Solution

  • Seems like the issue is in the scale label template definition.

    TLDR: Once you rename the template like the following, it should work:

    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);
    };
    

    Right now you have it declared like this:

    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);
    };
    

    Where the name of the template is weektimeline_scale_label. But the timeline view is declared under the timeline name:

    scheduler.createTimelineView({
    ...
        name:"timeline", 
    ...
    }); 
    

    The template must contain the name of the timeline view (since the scheduler allows creating multiple timelines), i.e. **scheduler.templates[${timeline.name}_scale_label].

    So in your case, the template should be named 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);
    };
    

    or

    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);
    };
    

    Snippet: https://snippet.dhtmlx.com/5/7ef709780

    Also note, that the Day Timeline view doesn't support markers (scheduler.addMarkedTimespan), but you can color cells using scheduler.templates.timeline_cell_class template:

    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 "";
    };
    

    Here is a demo: https://snippet.dhtmlx.com/sxorcz6s