Yes, you can do it using the onBeforeCellRender event, like this:
onBeforeCellRender: args => {
if (args.cell.row.data && args.cell.row.data.frozen) {
const events = scheduler.events.forRange(args.cell.start, args.cell.end);
const total = events.reduce((sum, event) => sum + event.data.tags.cost), 0);
args.cell.text = `$ ${total}`;
}
}
The events.forRange() method finds all events in the specified date range. If you have events longer than one cell, they will be included in multiple columns.
The code above assumes that you have a frozen row at the top of the Scheduler dedicated for the totals:
const resources = [
{ name: "Total", id: "total", frozen: "top" },
// ...
// other resources
};
scheduler.update({resources});