html5-scheduler-selecting-multiple-ranges.png

Available since DayPilot Pro 8.0.

You can enable selecting of multiple time ranges at once.

  • This feature is disabled by default.
  • Hold Ctrl (Command on Mac) to select multiple ranges. As soon as you release the Ctrl key the TimeRangeSelected event will be fired.
  • If event overlap prevention is enabled it will not be possible to add a conflicting range.
  • Multiple time range selecting will work for more than scheduler controls on the page. TimeRangeSelected will only be fired for the control with the range that was added last.

JavaScript

Enable range multi-selecting using allowMultiRange property:

dp.allowMultiRange = true;

The selected ranges will be available in onTimeRangeSelect and onTimeRangeSelected event handlers as args.multirange:

dp.onTimeRangeSelected = function(args) {
  var name = prompt("New event name:", "Event");
  if (!name) return;

  var ranges = dp.multirange;

  ranges.each(function(item) {
      var e = new DayPilot.Event({
          start: item.start,
          end: item.end,
          id: DayPilot.guid(),
          resource: item.resource,
          text: name
      });
      dp.events.add(e);
  });

  dp.clearSelection();
  dp.message("Created");
}

You can also get an array of selected ranges using dp.range.all():

var ranges = dp.range.all();

The item structure: