Search
Resources

MindFusion.Scheduling for JavaScript lets you associate resources with scheduled events via the resources, contacts, location and task properties of Item objects. These properties contain objects from the Resource, Contact, Location and Task classes respectively. If you need to assign a resource to schedule items, you must also add the resource to the appropriate collection in the Schedule class, namely resources, contacts, locations or tasks.

The following code creates a new Location and adds it to the location property of an existing schedule item. It also adds the location to the schedule.locations collection:

JavaScript  Copy Code

var p = MindFusion.Scheduling;
location = new p.Location();
location.name = name;
location.address = "1, King’s road";
location.city = "Cambridge";
location.country = "USA";
location.state = "MA";
location.zipCode = 12345;

//assign the new location to the item
myItem.location = location;

//add the location to the list of locations of the schedule
calendar.schedule.locations.add(location);

Timetable, List and Resource views let you display distinct rows or columns for selected resources and to group items by their associated resources. To enable that, add the resources of interest to the appropriate resource collection of the Calendar object (that is, resources, contacts, locations and tasks respectively) and set the calendar.groupType property to the appropriate value.

The following method imports the contacts aor tasks, depending on the group criteria, to the calendar:

JavaScript  Copy Code

var p = MindFusion.Scheduling;

function group(value) {
 calendar.contacts.clear();
 if (value == p.GroupType.GroupByContacts) {
  // add the contacts by which to group to the calendar.contacts collection
  calendar.contacts.addRange(calendar.schedule.contacts.items());
 }
 calendar.tasks.clear();
 if (value == p.GroupType.GroupByTasks) {
  // add the resources by which to group to the calendar.tasks collection
  calendar.tasks.addRange(calendar.schedule.tasks.items());
 }
 calendar.groupType = value;
}

The class Resource is the base class of Contact, Location and Task. It defines an Id property, which must be unique among all resources in the schedule, and serialization methods.

All calendar views provide means to filter out items, based on resources they contain. To see if there is any filtering or grouping enabled on the client, check the value of the groupType property.