TypeError: Cannot read property 'getEvents' of undefined
at ResourceInfoColumn.template (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:376453)
at ResourceInfoColumn.defaultRenderer (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:376529)
at Row.renderCell (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:310191)
at Row.render (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:310040)
at RowManager.renderRows (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:311466)
at VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:367181
at SchedulerPro.runWithTransition (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:362318)
at HorizontalRendering.refreshResources (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:367177)
at HorizontalRendering.onEventStoreChange (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:366781)
at SchedulerPro.onInternalEventStoreChange (VM471 vendors-node_modules_babel_runtime_helpers_esm_createSuper_js-node_modules_date-io_date-fns_b-28d77b.iframe.bundle.js:364622)
Last edited by david10sing on Wed May 19, 2021 1:06 pm, edited 1 time in total.
Give us please more information, ideally a showcase that exhibits this issue. I've tried to call project.loadCrudManagerData with the above data on https://bryntum.com/examples/scheduler-pro/percent-done/ without the above error.
const schedulerInstance: Ref<BryntumSchedulerPro> = useRef(null);
useEffect(() => {
if (rpState.filters && rpState.schedulerInstance) {
/**
* Because we are switching from group by project
* and the other group by options, we need to
* nullify the tooltipData.
*/
setTooltipData(null);
rpDispatch({
type: Actions.fetchData,
});
/**
* Append filters to url params
*/
withDeepLink.appendFiltersToURL(rpState.filters);
/**
* Need to do this because if the view is grouped
* a server request will throw an error client side.
* So we need to expand all the headers first to prevent
* the error.
* Also removing all the resources so expanding the groups
* is not shown client side
*/
const scheduler = schedulerInstance.current.instance; <<<<<<< DOESN'T WORK
scheduler.expandAll();
scheduler.resourceStore.removeAll();
scheduler.refresh();
fetchResources(rpState)
.then(res => {
if (!res) {
throw new Error();
}
return res;
})
.then(res => {
/**
* Loop through the bookings to set time on PTO bookings
* so they render properly.
*
* Also filter out any bookings that end up on a weekend
*/
res.events.rows = res.events.rows
.map(event => {
const isoStartDate = parseISO(event.startDate);
const isoEndDate = parseISO(event.endDate);
if (isWeekend(isoStartDate) && isWeekend(isoEndDate)) {
return;
}
if (event.ptoRequestId && isSameDay(isoStartDate, isoEndDate)) {
event.endDate = event.endDate.replace('00:00:00', '23:59:59');
}
return event;
})
.filter(event => event);
rpDispatch({
type: Actions.setLoadingFalse,
});
/**
* There is an error with group by project and
* it has been reported to Bryntum.
*
* If error occurs, then we force a reload of the page
*/
try {
scheduler.project.loadCrudManagerData(res);
} catch (err) {
console.log(err);
window?.utilities?.notification.danger('An error occured. Refreshing Page.');
setTimeout(() => window.location.reload(), 2000);
}
})
.catch(error => {
IS_DEV && console.log(error);
});
}
}, [rpState.filters, rpState.jq, rpState.reload]);
This block worked when I used the schedulerInstance in a react context.
const schedulerInstance: Ref<BryntumSchedulerPro> = useRef(null);
useEffect(() => {
if (rpState.filters && rpState.schedulerInstance) {
/**
* Because we are switching from group by project
* and the other group by options, we need to
* nullify the tooltipData.
*/
setTooltipData(null);
rpDispatch({
type: Actions.fetchData,
});
/**
* Append filters to url params
*/
withDeepLink.appendFiltersToURL(rpState.filters);
/**
* Need to do this because if the view is grouped
* a server request will throw an error client side.
* So we need to expand all the headers first to prevent
* the error.
* Also removing all the resources so expanding the groups
* is not shown client side
*/
const scheduler = rpState.schedulerInstance; <<<<<<< WORKS
scheduler.expandAll();
scheduler.resourceStore.removeAll();
scheduler.refresh();
fetchResources(rpState)
.then(res => {
if (!res) {
throw new Error();
}
return res;
})
.then(res => {
/**
* Loop through the bookings to set time on PTO bookings
* so they render properly.
*
* Also filter out any bookings that end up on a weekend
*/
res.events.rows = res.events.rows
.map(event => {
const isoStartDate = parseISO(event.startDate);
const isoEndDate = parseISO(event.endDate);
if (isWeekend(isoStartDate) && isWeekend(isoEndDate)) {
return;
}
if (event.ptoRequestId && isSameDay(isoStartDate, isoEndDate)) {
event.endDate = event.endDate.replace('00:00:00', '23:59:59');
}
return event;
})
.filter(event => event);
rpDispatch({
type: Actions.setLoadingFalse,
});
/**
* There is an error with group by project and
* it has been reported to Bryntum.
*
* If error occurs, then we force a reload of the page
*/
try {
scheduler.project.loadCrudManagerData(res);
} catch (err) {
console.log(err);
window?.utilities?.notification.danger('An error occured. Refreshing Page.');
setTimeout(() => window.location.reload(), 2000);
}
})
.catch(error => {
IS_DEV && console.log(error);
});
}
}, [rpState.filters, rpState.jq, rpState.reload]);
Why would this matter just because I am now sending resourceTimeRanges in the response payload?