Hello, I'm attempting to create a simple button that calls this method outlined in your documentation:
https://ej2.syncfusion.com/react/documentation/schedule/appointments/#refresh-appointments
It does not seem to work for me.
One difference is that I'm using functional React, so I'm using useRef() to access the component. I can log the scheduler to the browser console, and browsing the schedule object I find that the refreshEvents() method can be found under a Prototype, but I can't call that method in my code.
I am hoping as well that I can have the scheduler show a spinner or something to let the user know that a refresh action has been initiated.
|
const scheduleObj = useRef<ScheduleComponent>(null);
const onButtonClick = () => {
if (scheduleObj.current) {
scheduleObj.current.showSpinner(); // show the spinner
setTimeout(function () {
if (scheduleObj.current) {
scheduleObj.current.refreshEvents(); // refreshing the events
scheduleObj.current.hideSpinner(); // hide the spinner
}
}, 5000);
}
};
const onDataBound = () => {
console.log("Events refreshed") // ensuring the events are properly refreshed.
}
return (
<div>
<ButtonComponent id='add' title='RefereshEvents' onClick={onButtonClick}>Referesh Events</ButtonComponent>
<ScheduleComponent id="schedule" height="550px" ref={scheduleObj} eventSettings={{ dataSource: data}}
cssClass='event-template' dataBound={onDataBound} showQuickInfo={false} allowResizing={false}>
<ViewsDirective>
<ViewDirective option={Browser.isDevice ? 'Day' : 'Week'} />
<ViewDirective option={Browser.isDevice ? 'TimelineDay' : 'TimelineWeek'} />
</ViewsDirective>
<Inject services={[Day, Week, TimelineViews, Resize, DragAndDrop]} />
</ScheduleComponent>
</div>
);
|
|
const scheduleObj = useRef<ScheduleComponent>(null);;
const onButtonClick = () => {
if (scheduleObj.current) {
scheduleObj.current.showSpinner(); // show the spinner
setTimeout(function () {
if (scheduleObj.current) {
scheduleObj.current.refreshEvents(); // refreshing the events
scheduleObj.current.hideSpinner(); // hide the spinner
}
}, 5000);
}
};
|