Our pure JavaScript Scheduler component


Post by netten.mehra »

Hi,
my team is trying to make a Proof of Concept with the Trial Version. We are working with the normal Scheduler and trying to access the EventStore through Ref. The EventStore is undefined and that's why we can't add new Data to the Scheduler.

We tried to use the basic example of React but the in our case the eventStore was still undefined.

Are we something missing to add or is this a Bug?

Version 4.3.2


Post by saki »

Does the unmodified React simple example work for you locally? That example contains addClickHandler that shows how to access the eventStore:

    const addClickHandler = useCallback(
        event => {
            // Get the scheduler instance
            const scheduler = schedulerRef.current?.instance;

            if (!scheduler) {
                return;
            }

            // Get start and end date of the new event (1h duration)
            const startDate = new Date(scheduler.startDate.getTime()),
                endDate = new Date(startDate.getTime()),
                resource = scheduler.resourceStore.first;

            if (!resource) {
                Toast.show('There is no resource available');
                return;
            }

            endDate.setHours(endDate.getHours() + 1);

            // Add the event to the store
            scheduler.eventStore.add({
                resourceId: resource.id,
                startDate: startDate,
                endDate: endDate,
                name: 'New task',
                eventType: 'Meeting'
            });
        },
        [schedulerRef]
    );

If you are still in troubles, post please your code, we'll investigate.


Post Reply