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

How to detect the end of a row move session?

Asked by Andy
23 days ago.

Hello,

Objective: I am looking to perform some logic at the beginning and end of a session, but I can’t figure out how to detect when the next position is `forbidden`, given the doc says “The Scheduler control fires the onRowMove and onRowMoved events on drop (if the target position is not forbidden).”

My attempt is as followed:

  • Use `onRowMoving` to detect the beginning of a move session

onRowMoving(){
  fnToCallWhenMoveStart();

  const nextPosition = validateMove(...); // return `forbidden` if failed validation

  args.position = nextPosition;
}
  • Use `onRowMove` to detect the end of a move session, but `fnToCallWhenMoveEnd` is not reached if user drops onto a `forbidden` position.

onRowMove(){
  fnToCallWhenMoveEnd();
}

Could you provide some guidance?

Answer posted by Dan Letecky [DayPilot]
23 days ago.

In the latest sandbox build (2025.3.6658), the Scheduler supports a new property (rowMoveFireOnForbiddenTarget) that lets you configure this.

Comment posted by Andy
23 days ago.

Thank you, Dan. This resolves the original issue perfectly.

I have another question.

I noticed that `onRowMove` is not called when user drops outside of the left resource pane (ie: like on a random place on the screen, not within the scheduler).

Is that intentional? If it is, how do we detect that?

Comment posted by Dan Letecky [DayPilot]
23 days ago.

Yes, this event is only fired for valid actions.

Maybe you could describe your use case in more detail, maybe there is a better/more universal solution that would cover it.

Comment posted by Andy
23 days ago.

That makes sense.

The use case is we want to collapse all the siblings of the (single) row being moved when the move session starts.

const activeMovedRowIdRef = useRef(null);

onRowMoving(args){
  if(!activeMovedRowIdRef.current) {
    activeMovedRowIdRef.current = args.row.id();
   
    collapseSibling(args.row.id);
  }

}

onRowMoveEnd(args){
 activeMovedRowIdRef.current = null;

 // do something
}

When the move ends (regardless of drop position, invalid or not), we want to reset `activeMovedRowIdRef` to null.

Problem: If user drops resource invalidly outside of scheduler, `onRowMoveEnd` will not be called, meaning the active row id is not reset and `collapseSibling` won’t be called again.

Note that after the first invalid drop, user can have expand some siblings before initiating the drag of the same row again.

Comment posted by Dan Letecky [DayPilot]
22 days ago.

Thanks for the details, Andy.

Please see React Scheduler > Uncaught Error when moving resource after collapse for a solution.

Comment posted by Andy
21 days ago.

Hi Dan,

Unfortunately, I think it is only partial solution, but doesn’t resolve the problem in which `onRowMoveEnd` will not be called if we move the resource row outside of the valid drop zone (ie: the resource pane), meaning `activeMovedRowIdRef.current` won’t be reset to `null`.

New Reply
This reply is
Attachments:
or drop files here
Your name (optional):