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

How to clear the previous event from calendar if the updated event list is empty/null?

Asked by jaris
1 year ago.

The Calendar updates correctly when i change the eventData, but if its empty its not updating and shows the previous data

          <DayPilotCalendar
            cellHeight="50"
            viewType="Day"
            startDate={date}
            onTimeRangeSelected={async (e) => {
              setStartTime(e.start.toString());
              setEndTime(e.end.toString());
              setOpenDialog(true);
            }}
            eventDeleteHandling="Update"
            onEventClicked={(event) => {
              setEventDataOfSchedule(event.e.data);
              handleClickOpen();
            }}
            events={eventData}
            onEventDelete={async (event) => {
              // eslint-disable-next-line no-restricted-globals
              if (!confirm("Do you really want to delete this event?")) {
                event.preventDefault();
              }
            }}
          />
Comment posted by Dan Letecky [DayPilot]
1 year ago.

Have you tried using an empty array instead of "null" for the empty value?

Comment posted by jaris
1 year ago.

I fixed it by giving an empty array, at first i was setting the eventData as ([{}]) instead of empty array if the response was null, and that was giving me error because it needs a start property, i thought there was something else for it, thanks

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

Great, thanks for the update.

In the latest sandbox build (2023.1.444), the Calendar component now accepts null as well and treats it as []:
https://release.daypilot.org/changes/jslite/

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