Load Resources on Demand
Usage
theme="ios" You can turn auto theming on and let it decide based on the platform.
Usage
themeVariant="light" You can turn auto dark mode on based on system settings.
Usage
clickToCreate={true}
// click to create is on dragToCreate={true}
// drag to create is on dragToMove={true}
// reordering is on dragToResize={true}
// resizing is on eventDelete={true}
// deleting is on Fine-tune drag & drop with these options, which are false by default.
Usage
locale={localeEn} Selecting the locale loads the localized settings and the translated UI text.
Load Resources on Demand
The resources can be populated on initialization or in case of a bigger hierarchy, the more efficient way is to load the child resources and their events on demand.
Getting the resources and the events in real time as the user navigates improves load performance.
Use the onResourceExpand lifecycle event to load the data runtime. You can learn about lifecycle events and places where to drop logic to customize the experience.
Demo

Code
View code on GitHub
import { Eventcalendar, getJson, setOptions, Toast } from '@mobiscroll/react';
import { useCallback, useMemo, useState } from 'react';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
function App() {
const [isToastOpen, setToastOpen] = useState(false);
const [myResources, setResources] = useState([
{
id: 1,
name: 'Group 1',
collapsed: true,
eventCreation: false,
children: [
{
id: 11,
color: '#e20000',
name: 'Resource 1',
},
{
id: 12,
color: '#76e083',
name: 'Resource 2',
},
{
id: 13,
color: '#4981d6',
name: 'Resource 3',
},
],
},
{
id: 2,
name: 'Group 2',
collapsed: true,
eventCreation: false,
children: [
{
id: 21,
name: 'Loading...',
},
],
},
{
id: 3,
name: 'Group 3',
collapsed: true,
eventCreation: false,
children: [
{
id: 31,
name: 'Loading...',
},
],
},
{
id: 4,
name: 'Group 4',
collapsed: true,
eventCreation: false,
children: [
{
id: 41,
name: 'Loading...',
},
],
},
{
id: 5,
name: 'Group 5',
collapsed: true,
eventCreation: false,
children: [
{
id: 51,
color: '#af0000',
name: 'Resource 12',
},
{
id: 52,
color: '#446f1c',
name: 'Resource 13',
},
{
id: 53,
color: '#1dab2f',
name: 'Resource 14',
},
],
},
{
id: 6,
name: 'Resource 17',
color: '#167593',
},
{
id: 7,
name: 'Resource 18',
color: '#93166c',
},
{
id: 8,
name: 'Resource 19',
color: '#e5e923',
},
{
id: 9,
name: 'Resource 20',
color: '#935028',
},
]);
const [myEvents, setEvents] = useState([
{
start: '2026-11-04T10:00',
end: '2026-11-04T13:00',
title: 'Event 14',
resource: 6,
},
{
start: '2026-11-04T15:00',
end: '2026-11-04T17:30',
title: 'Event 15',
resource: 7,
},
{
start: '2026-11-04T09:00',
end: '2026-11-04T11:00',
title: 'Event 16',
resource: 8,
},
{
start: '2026-11-04T17:00',
end: '2026-11-04T20:00',
title: 'Event 17',
resource: 9,
},
]);
const myView = useMemo(
() => ({
timeline: { type: 'day' },
}),
[],
);
const loadChildResources = useCallback(
(args) => {
const resource = args.resourceObj;
if (!resource.loaded) {
getJson(
'https://trial.mobiscroll.com/load-resources/?res=' + args.resource,
(data) => {
const newEvents = [...myEvents, ...data.events];
resource.children = data.resources;
resource.loaded = true;
setEvents(newEvents);
setResources([...myResources]);
setToastOpen(true);
},
'jsonp',
);
}
},
[myEvents, myResources, setToastOpen],
);
const handleCloseToast = useCallback(() => {
setToastOpen(false);
}, []);
return (
<>
<Eventcalendar
clickToCreate={ }
dragToCreate={ }
dragToMove={ }
dragToResize={ }
eventDelete={ }
view={myView}
resources={myResources}
data={myEvents}
onResourceExpand={loadChildResources}
className="md-load-resources-on-demand"
/>
<Toast message="Resources loaded" isOpen={isToastOpen} onClose={handleCloseToast} />
</>
);
}
export default App;
import {
Eventcalendar,
getJson,
MbscCalendarEvent,
MbscEventcalendarView,
MbscResource,
MbscResourceExpandEvent,
setOptions,
Toast ,
} from '@mobiscroll/react';
import { FC, useCallback, useMemo, useState } from 'react';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
const App: FC = () => {
const [isToastOpen, setToastOpen] = useState<boolean>(false);
const myView = useMemo<MbscEventcalendarView>(
() => ({
timeline: { type: 'day' },
}),
[],
);
const [myResources, setResources] = useState<MbscResource[]>([
{
id: 1,
name: 'Group 1',
collapsed: true,
eventCreation: false,
children: [
{
id: 11,
color: '#e20000',
name: 'Resource 1',
},
{
id: 12,
color: '#76e083',
name: 'Resource 2',
},
{
id: 13,
color: '#4981d6',
name: 'Resource 3',
},
],
},
{
id: 2,
name: 'Group 2',
collapsed: true,
eventCreation: false,
children: [
{
id: 21,
name: 'Loading...',
},
],
},
{
id: 3,
name: 'Group 3',
collapsed: true,
eventCreation: false,
children: [
{
id: 31,
name: 'Loading...',
},
],
},
{
id: 4,
name: 'Group 4',
collapsed: true,
eventCreation: false,
children: [
{
id: 41,
name: 'Loading...',
},
],
},
{
id: 5,
name: 'Group 5',
collapsed: true,
eventCreation: false,
children: [
{
id: 51,
color: '#af0000',
name: 'Resource 12',
},
{
id: 52,
color: '#446f1c',
name: 'Resource 13',
},
{
id: 53,
color: '#1dab2f',
name: 'Resource 14',
},
],
},
{
id: 6,
name: 'Resource 17',
color: '#167593',
},
{
id: 7,
name: 'Resource 18',
color: '#93166c',
},
{
id: 8,
name: 'Resource 19',
color: '#e5e923',
},
{
id: 9,
name: 'Resource 20',
color: '#935028',
},
]);
const [myEvents, setEvents] = useState<MbscCalendarEvent[]>([
{
start: '2026-11-04T10:00',
end: '2026-11-04T13:00',
title: 'Event 14',
resource: 6,
},
{
start: '2026-11-04T15:00',
end: '2026-11-04T17:30',
title: 'Event 15',
resource: 7,
},
{
start: '2026-11-04T09:00',
end: '2026-11-04T11:00',
title: 'Event 16',
resource: 8,
},
{
start: '2026-11-04T17:00',
end: '2026-11-04T20:00',
title: 'Event 17',
resource: 9,
},
]);
const loadChildResources = useCallback(
(args: MbscResourceExpandEvent) => {
const resource = args.resourceObj!;
if (!resource!.loaded) {
getJson(
'https://trial.mobiscroll.com/load-resources/?res=' + args.resource,
(data) => {
const newEvents = [...myEvents, ...data.events];
resource!.children = data.resources;
resource!.loaded = true;
setEvents(newEvents);
setResources([...myResources]);
setToastOpen(true);
},
'jsonp',
);
}
},
[myEvents, myResources],
);
const handleCloseToast = useCallback(() => {
setToastOpen(false);
}, []);
return (
<>
<Eventcalendar
clickToCreate={ }
dragToCreate={ }
dragToMove={ }
dragToResize={ }
eventDelete={ }
view={myView}
resources={myResources}
data={myEvents}
onResourceExpand={loadChildResources}
className="md-load-resources-on-demand"
/>
<Toast message="Resources loaded" isOpen={isToastOpen} onClose={handleCloseToast} />
</>
);
};
export default App;
.md-load-resources-on-demand .mbsc-timeline-parent {
height: 34px;
}