0

In a scheduler timeline view having a second_scale, is it possible to click on a single date? I have found this answer, but I'm wondering if there is an event in the meantime.

enter image description here

cwhisperer
  • 1,478
  • 1
  • 32
  • 63

1 Answers1

1

There are onXScaleClick, onXScaleDblClick events for the Timeline view. But in case, when you have 2 scales, they fire only for the second one. Check console in the snippet that demonstrates it.

Nonetheless, you can add onclick event listener for the first scale using js:

var dateScaleEl = document.querySelector(".dhx_second_scale_bar");
dateScaleEl.onclick = function() {
    var targetDate = scheduler.getState().date;
    console.log(targetDate);
}

Demo.

getState() is a method to get the active date.

Polina
  • 412
  • 2
  • 6
  • onXScaleClick is working fine. The onclick event listener added via js is not working but I don't know why. There is no error. I'm also able to console.log(dateScaleEl) but it seems like the click event is not attached. – cwhisperer Dec 10 '19 at 09:18
  • onclick event is attached properly in the demo in my reply above: https://gyazo.com/2ced86bd840c370c364eb0aeb7815548 . Please pay attention, that you should get the element with ".dhx_second_scale_bar" selector after Scheduler initialization. – Polina Dec 10 '19 at 13:23
  • Yes, I took care about this, thx. console.log(dateScaleEl); returns the whole div but the onclick is not affected. – cwhisperer Dec 10 '19 at 13:37
  • It works now. I put your code in scheduler.attachEvent("onLoadEnd", function () {}); – cwhisperer Dec 17 '19 at 09:39