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

Why Group use alway return 0 in the fist time run?

Related article: JavaScript Scheduler: Displaying Group Availability
Asked by Anonymous
7 days ago.

In the first time the project run, it alway return 0 for "used" variable; If i change the view, then come back first view, it will render and caculate used?

onBeforeCellRender: args => {
      if (args.cell.isParent) {
        var children = this.scheduler.control.rows.find(args.cell.resource).children();
        var total = children.length;
        var used = children.filter(function(row) { return !!row.events.forRange(args.cell.start, args.cell.end).length; } ).length;
        var available = total - used;
        var color = "white"
        var w = this.cellWidth / total;
        args.cell.properties.areas = [];
        args.cell.properties.areas.push({
          html: "" + used,
          // style: "text-align: center; font-size: 12px; font-weight: bold",
          top: 0,
          left: 0,
          right: 0,
          bottom: 0,
          backColor: color
        });
        
      }   
    },
Answer posted by Dan Letecky [DayPilot]
7 days ago.

The "used" value will be 0 before the events are loaded. The result of onBeforeCellRender is cached and in most cases the caching needs to be disabled using "cellsAutoUpdated" property of the parent resources, as explained in the tutorial.

New Reply
This reply is
Your name (optional):