Get the value of y_property in timeline view (in bar mode)

Hi there, i want to get a value of y_property and use it for something, when i click on an empty cell to create a new event. For example, here - https://docs.dhtmlx.com/scheduler/samples/06_timeline/02_lines.html i click on John Williams 9.30-10.00 time cell and i want to console.log() John Williams or it’s key. How can i do it? I know, that in a popup John Williams will be selected, but i do not want to grab the selected value of this selection to perform this task. I am sure thet there is some variable for this…Can you tell me, how to do this?

And one more little question - can i change the default time period, that is selected in a popup when i try to add a new event to a smaller one (example is the same - https://docs.dhtmlx.com/scheduler/samples/06_timeline/02_lines.html)? For example, if i click on 9.30-10.00 time cell, there will be a selected period of 9.30 - 10.00 in a “time period” in a popup, but i want to make it 0.5 of this period, so it have to be 9.30 - 9.45 selected. How can i do it?

Hello @AlexMav ,

You can get the section(and other data) under the mouse pointer with the getActionData method:
https://docs.dhtmlx.com/scheduler/api__scheduler_getactiondata.html

Here is an example of usage(click on the empty space in the timeline to get the section id in browser console):
http://snippet.dhtmlx.com/5/31fd06ce1

1 Like

Hello @AlexMav ,

Regarding the second question:

You can manually change the initial end time of the event created in the timeline view using the onEventCreated event:
https://docs.dhtmlx.com/scheduler/api__scheduler_oneventcreated_event.html

The code may look like follows:

scheduler.attachEvent("onEventCreated", function(id,e){
  if(scheduler.getState().mode === "timeline" && e && e.type ==  "dblclick"){

    var event = scheduler.getEvent(id);
    event.end_date = scheduler.date.add(event.start_date, 15, "minute");
    scheduler.updateEvent(id);
  }
  return true;
});

Here is a demo:
http://snippet.dhtmlx.com/5/f2288b561

1 Like

Your answers are so perfect, as they can be. Great!