Events not drawn as expected

Hi

See image below

html part
<ejs-schedule
            :eventSettings="eventSettings"
            :firstDayOfWeek="getFirstDayOfWeek"
            :views="views"
            :selectedDate="selectedDate"
            :currentView="sView"
            style="flex: 1"
            :allowDragAndDrop="allowDragAndDrop"
            readonly="true"
            :eventRendered="onEventRendered"
            :showHeaderBar="showHeaderBar"
            ref="scheduleObj"
            :actionBegin="onActionBegin"
            :popupOpen="onPopupOpen"
        />

code part (events are not there to begin with, they are retrieved from the server and pushed at runtime)
for (var item in response.data.result) {
    this.eventsData.push({
        ...
    });
}
let scheduleObj = document.querySelector(".e-schedule").ej2_instances[0];
scheduleObj.eventSettings.dataSource = this.eventsData;
scheduleObj.refresh();

I tried using setTimeout to refresh the component but it didn't help.
Please advice
Thanks

3 Replies 1 reply marked as answer

HB Hareesh Balasubramanian Syncfusion Team March 29, 2021 08:46 AM UTC

Hi Amos, 

Greetings from Syncfusion Support..! 

We have validated your shared snippets at our end and suspect that your requirement is to “render the events from the server at the runtime of the Scheduler”. And for the same, we have prepared a sample using dataBound event of the Scheduler, which can be downloaded from the following link. 


let dataManager = []; 
let flag = true; 
let ajax = new Ajax( 
  "GET", 
  false 
); 
ajax.onSuccess = function (value) { 
  dataManager = JSON.parse(value); 
}; 

onDataBound() { 
      if (flag) { 
        let schObj = document.querySelector(".e-schedule").ej2_instances[0]; 
        schObj.eventSettings.dataSource = dataManager; 
        flag = false; 
      } 
    }, 
  }, 

Kindly try the above solution and if you still face any problem please share where you assigned the dataSource to the scheduler or replicate the problem in above sample. 

We will be happy to assist you..! 

Regards, 
Hareesh 


Marked as answer

AM Amos March 29, 2021 05:51 PM UTC

As you can see, the events are drawn but as if there is not enough room for all the events per day.

Doing some more tests show that at first, the component is drawn much smaller than the available space and only after calling
scheduleObj.refresh();
The component is drawn correctly, covering all the available space but the events were already drawn.
So then, calling
scheduleObj.refreshEvents();
Makes it draw everything as it should be.

let scheduleObj = document.querySelector(".e-schedule").ej2_instances[0];
scheduleObj.eventSettings.dataSource = this.eventsData;
scheduleObj.refresh();
scheduleObj.refreshEvents();

It's the old story of a component not bounding itself to the css, I had this issue from time to time, usually with a grid and we always fixed it using workarounds.
Just a thought.


NR Nevitha Ravi Syncfusion Team March 30, 2021 09:16 PM UTC

Hi Amos, 

Thanks for your update. 

Since we are not able to replicate the issue at our end, could you please share the following details to provide prompt solution. 
  • Try to replicate the issue in a sample
  • Syncfusion scheduler package version
  • Issue depicting video

Regards, 
Nevitha 


Loader.
Up arrow icon