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

Listen to onEventMoving

Asked by Anonymous
5 months ago.

I need to listen to onEventMoved, in order to rearrange the order of some labels. This is something as:
- I open a sidebar
- I click on some services and load them.

If i drag and drop some elements, i need to rearrange the sidebar. What can i do?

Answer posted by Dan Letecky [DayPilot]
5 months ago.
  1. The onEventMoved event is fired when all updates are complete, and it’s fine to use it for updating either the calendar/scheduler itself or external elements.

  2. The onEventMoving event is fired in real time during drag-and-drop. You should limit actions to minor updates of external elements. Updating (reloading) the calendar/scheduler component in this context is not possible.

Comment posted by Anonymous
5 months ago.

How can i listen when calendarRef is called?

Comment posted by Dan Letecky [DayPilot]
5 months ago.

I’m not sure if that’s what you mean but since the last release (2023.4.5801), you can also use a new controlRef prop to get a reference directly to the DayPilot.Calendar object.

It accepts a ref or a callback so you can use it to store the reference in a state variable. The useEffect() block will be executed when the calendar value is set.

const [calendar, setCalendar] = useState();

useEffect(() => {
  console.log("DayPilot.Calendar is available", calendar);
}, [calendar]);

return (
  <DayPilotCalendar controlRef={setCalendar} />
};
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.