Hi,
I tried creating a scheduler that's supposed to render all events with a custom event template and custom data model but unfortunately was not able to render anything in the calendar.
I have tried adding the template from the eventSettings property but it's giving me a typescript error on incompatible types.
I tried the solution that I've found in one of the threads in your forum with an issue similar to mine and have reflected the suggested fix (other forum link here). It solve the type errors but it didn't render any of the sample events.
Here's link to the sample code:
https://stackblitz.com/edit/react-ts-c8qajf
Would like to know what caused the issue for the scheduler to not render the events.
|
const getTimeString = (value: Date) => {
var instance = new Internationalization();
return instance.formatDate(value, { skeleton: 'hm' }); }; const eventTemplate = (model: any) => {
debugger;
return (
<div>
<div className="template-wrap-title">{model.subject}</div>
<div className="template-wrap-data">
{getTimeString(model.startDate)}
</div>
<div className="template-wrap-data">{getTimeString(model.endDate)}</div>
</div>
);
};
return (
<div style={{ height: '98%', margin: '1%' }}>
<ScheduleComponent
width="100%"
height="100%"
selectedDate={new Date(2022, 1, 2)}
// delayUpdate="true"
ref={(t: ScheduleComponent) => (scheduleObj = t)}
eventSettings={{
dataSource: testData,
template: eventTemplate,
fields: {
startTime: { name: 'startDate' },
endTime: { name: 'endDate' },
},
}}
>
<ViewsDirective>
<ViewDirective option="Day" eventTemplate={eventTemplate} />
<ViewDirective option="Week" eventTemplate={eventTemplate} />
<ViewDirective option="Month" eventTemplate={eventTemplate} />
<ViewDirective option="Year" eventTemplate={eventTemplate} />
</ViewsDirective>
<Inject
services={[
Day,
Week,
WorkWeek,
Month,
Year,
Agenda,
Resize,
DragAndDrop,
]}
/>
</ScheduleComponent>
</div>
); }; |
I have tried out the suggested solution locally but I am running into a problem with the template.js.
I tried downloading the sample solution and created a fresh project out of it. Interestingly, I tried to add debugger breakpoints on the same lines but it never was triggered. However, there's another template.js under ej2-react-base which was the one being called. Is there a way to override this and force the component the use ej2-react-base rather than the ej2-base template.js?
I finally got it working on my end. It definitely had something to do with the inconsistent versions of the syncfusion react components installed in the project.
Also, the previous suggested solution worked perfectly.
Cheers!
Ercel
We are happy that your problem is resolved now.