search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Adding values of events than counting in Group Availability

Asked by WSJU
9 months ago.

Hi, I am looking at this example
and I see that it gives you a difference based on number of children.

Is there a quick way of using the same function in add up values (Event1, Event2 will integers instead of strings) and show it in the group level?

Answer posted by Dan Letecky [DayPilot]
9 months ago.

This example will calculate a sum of values stored in a specified event field ("val"):

onBeforeCellRender: (args) => {
  if (args.cell.isParent) {
    const field = "val";

    const children = dp.rows.find(args.cell.resource).children();
    const sum = children.reduce((acc, row) => {
      const events =, args.cell.end);
      const total = events.reduce((acc, e) => acc +[field], 0);
      return acc + total;
    }, 0);

    args.cell.html = "" + sum;

The event data object would look like this:

const events = [
    id: 1,
    // ...
    val: 3
    id: 2,
    // ...
    val: 5

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.