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
3 years 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]
3 years 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.

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