javascript - How can I extend the date display of the Gantt chart using DHTMLX Gantt? -
i creating planner , included gantt chart in it. problem trying create schedule start in march 31, 2016 , ends in april 15, 2016. problem graph doesn't display next month.
my process is, default graph load current month first , last day , displayed days.
here's sample code:
//get first , last day of current month var parsed = date.parse("today"); var firstofmonth = new date(parsed.getfullyear(),parsed.getmonth(), 1); var lastofmonth = new date(parsed.getfullyear(),parsed.getmonth()+1, 0); var f_firstofmonth = firstofmonth.tostring("yyyy-mm-dd"); var f_lastofmonth = lastofmonth.tostring("yyyy-mm-dd"); //assign empty gantt $(".mygantt").dhx_gantt({ data: '', start_date: f_firstofmonth, end_date: f_lastofmonth, scale_height: 50, scale_unit: "day", }); can me this? using this example here.
so want display current month default, , adjust displayed range new tasks added?
timeline range can defined start_date , end_date configs can changed dynamically, these changes applied after full redraw of gantt.
so can do:
add handler onbeforeganttrender event, fired before full redraw of gantt. entry point such settings.
inside handler can date range of tasks using gantt.getsubtaskdates , update start_date/end_date configs accordingly
each time user adds, updates or removes task you'll need trigger full redraw of gantt
you don't need start_date/end_date configs during data loading, since filter out tasks located outside current month
here complete demo http://docs.dhtmlx.com/gantt/snippet/7d86e912
Comments
Post a Comment