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

Displaying Group Availability without disable row

Asked by Alexandre
4 years ago.

Hi,

Could you please help me ?

My total and my used variable is wrong because admin can disable row.

The deactivated line always appears but must be removed from the calculations

You can find the file in attached

Thanks in advance

Answer posted by Dan Letecky [DayPilot]
4 years ago.

This is the code that calculates the group availability (https://code.daypilot.org/97538/javascript-scheduler-displaying-group-availability):

onBeforeCellRender: function(args) {
  if (args.cell.isParent) {
    var children = dp.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;

    args.cell.html = "" + available;
  }
}

The "children" variable holds all child rows. You need to apply a filter to remove the admin rows.

Let's assume the admin row is marked with "admin":true like this:

resources: [
  { name: "Group", id: "G1", children: [
      { name: "Row 1", id: 1 },
      { name: "Admin row", id: 2, admin: true }
    ]
  }
]

Then you can exclude the row like this:

onBeforeCellRender: function(args) {
  if (args.cell.isParent) {
    var children = dp.rows.find(args.cell.resource).children().filter(function(row) { return !row.data.admin; });
    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;

    args.cell.html = "" + available;
  }
}

Note this line:

    var children = dp.rows.find(args.cell.resource).children().filter(function(row) { return !row.data.admin; });
Comment posted by Alexandre
4 years ago.

Thank you for your feedback !

It's work fine

Comment posted by Prakash
4 years ago.

I want to use group availability in asp.net. Is it available in asp.net control?

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