Hi Tingting,
Greetings from Syncfusion support.
We have validated your query “Is there anyway that I can
setup auto refresh with datamanager like every 3 minutes?” at our end. You
can achieve your requirement with help of a Schedule created and destroyed
events of the Schedule as shown in the below code snippet using setInterval.
Sample: https://stackblitz.com/edit/ej2-react-schedule-refresh-data-every-3-minutes?file=index.js
[index.js]
function RemoteData() {
let scheduleObj;
let timer;
const dataManager = new DataManager({
url: http://localhost:54738/Home/LoadData,
crudUrl: http://localhost:54738/Home/UpdateData,
adaptor: new UrlAdaptor,
crossDomain: true
});;
const onCreated = () => {
timer = setInterval(() => { scheduleObj.refreshEvents(); }, 180000);
}
const onDestroyed = () => {
clearInterval(timer);
}
return (
<ScheduleComponent width='100%' height='650px' selectedDate={new Date(2021, 1, 15)} ref={t => scheduleObj = t} eventSettings={{ dataSource: dataManager }} created={onCreated.bind(this)} destroyed={onDestroyed.bind(this)}>
<Inject services={[Day, Week, WorkWeek, Month, Agenda, Resize, DragAndDrop]} />
</ScheduleComponent>
);
}
|
Kindly try the shared solution and let us know if you need
any further assistance on this.
Regards,
Ravikumar Venkatesan
Attachment:
ej2reactscheduleremotedataservicesample_48b75147.zip