Adjust timeline view on the fly

Is it possible to adjust the timeline view on the fly using a function?

For example:

After I have run and initiated the view, can I just do this which will redraw the timeline?

scheduler.timelineView.x_unit =	"day";
scheduler.timelineView.x_date=	"day #%d";
scheduler.timelineView.x_step=	"1";

Hello,

It’s possible but not that easy.

  1. Open your codebase\ext\dhtmlxscheduler_timeline.js file
    Locate:
scheduler[O.name+"_view"]=function(){scheduler.renderMatrix.apply(O,arguments)};

Move it after

scheduler.callEvent("onOptionsLoad",[O]);

in the beginning of the file.

So you should get:

scheduler.callEvent("onOptionsLoad",[O]); scheduler[O.name+"_view"]=function(){scheduler.renderMatrix.apply(O,arguments)};

  1. Now in you code you can do something like this:

var btn = document.getElementById('btn'); btn.onclick = function() { scheduler.createTimelineView({ name: "timeline", x_unit: "minute", x_date: "%H:%i", x_step: 30, x_size: 5, x_start: 16, x_length: 48, y_unit: sections, y_property: "section_id", render:"bar" }); scheduler.setCurrentView(scheduler.getState().date, scheduler.getState().mode); };
So you can not change only one option on the fly, you need to recreate timeline view. I believe it would be handy to store settings in some object, change only one (or several) properties and then recreate view using with options object.

Best regards,
Ilya

That seems to be good, thank you. The next question is how do I capture a double click on the x header colum (date) in timeline mode? I thought I could use the onXScaleDblClick event handler?

I need to get the date of the column that I have doubled clicked on.

Thank you for your help.

That’s correct.

scheduler.attachEvent("onXScaleDblClick", function(x, date, event_object){ // your custom code });
should do the trick.

Best regards,
Ilya