Search code examples
dhtmlxgantt-chart

dhtmlx gantt tindex definition


http://docs.dhtmlx.com/gantt/api__gantt_onbeforerowdragend_event.html

Based on the dhtmlx gantt docs, this gives me a tindex params. However, this gives me the target index based on the dhtmlx tree on the front end. One of the fewest ways I can get a task via an ID (based on the id itself of the task, not based off of the dhtmlx tree) is via gantt.getTask(id). Is there way where I can achieve this? i.e.: get the task of the target index from onBeforeRowDragEnd ?


Solution

  • There is some confusion with event arguments. onBeforeRowDragEnd is fired when the task is moved to the new position. At that point a dragged item already has a new parent and an index within the tree and arguments provides an initial (old) state. I.e. if you cancel the event gantt will use these values to move the task back to it's original position, you can check that place in sources.

    So, when the handler is called the target index is already assigned to the task and you can retrieve it using gantt.getGlobalTaskIndex(taskId) method.

    Here is a sample: http://docs.dhtmlx.com/gantt/snippet/3b4b20d5