We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

refresh using datamanager

Hi,

I am using DataManager to provide data for my schedule component. Is there anyway that I can setup auto refresh with datamanager like every 3 minutes?


Thanks.


1 Reply

RV Ravikumar Venkatesan Syncfusion Team October 14, 2022 02:02 PM UTC

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(2021115)} ref={t => scheduleObj = t} eventSettings={dataSource: dataManager }} created={onCreated.bind(this)} destroyed={onDestroyed.bind(this)}>

      <Inject services={[DayWeekWorkWeekMonthAgendaResizeDragAndDrop]} />

    </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

Loader.
Live Chat Icon For mobile
Up arrow icon