search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

DayPilot.Gantt.onRowMoving with multiple positions

Asked by Leo
1 year ago.

We want to ensure that some DayPilot.Task elements cannot be converted to groups/parents when another Row is being dragged/moved on top of it.

However, it seems that args.position only allows for either "child", "before", "after" or "forbidden".

Is there any way to set “before“ and “after“, or only disallow child?

Otherwise, we run into the issue that some Rows cannot be dragged before or after the last Row item, as we seem to be able to only set before or after.

Answer posted by Dan Letecky [DayPilot]
1 year ago.

There are two options:

1. In the latest sandbox build (2023.3.5737), there is a new rowMoveSameLevelOnly property that lets you limit the target position of a row to the same level in the hierarchy of tasks.

2. In the onRowMoving event handler, you can check the conditions and forbid the "child" target position if that would mean converting an existing task into a group:

onRowMoving: args => {
  const targetIsGroup = args.target.children().length > 0;
  if (!targetIsGroup && args.position === "child") {
      args.position = "forbidden";
  }
}
Comment posted by Leo
1 year ago.

Many thanks for the swift response!

I wasn’t aware I could check on args.position. That solved it!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.