Search
Schedule Items

Events scheduled to occur at an appointed time are represented in MindFusion.Scheduling for JavaScript by the Item class. Item comprises the information that should be defined for all schedule events. The startTime and endTime properties of an Item specify the time and duration of an event. The recurrence property lets you create recurrent events that occur repeatedly following some recurrence pattern. There are several descriptive properties that define additional information about an Item, such as priority, subject and details. The class also defines methods that support serialization in JSON and XML formats.

The following code creates a new item for a birthday celebration that takes the whole present day and searches for the correct location:

JavaScript  Copy Code

var p = MindFusion.Scheduling;

var date = p.DateTime.today();

// create a new item
var item = new p.Item();
item.subject = "Birthday Celebration";   
item.startTime = date;
item.endTime = p.DateTime.addDays(date.clone(),1);
item.allDayEvent = true;
item.location = getLocation(item.subject);

It is possible to associate resources with scheduled events via the resources, contacts, location and task properties of Item. These properties contain objects from the Resource, Contact, Location and Task classes respectively.

The appearance of items when viewed in the Calendar can be set through CSS styles, which let you define the color, alignment and style of various elements of the item visualization, fill, icon images, and so on.

The following code uses Item.cssClass to set the color of the item from an array as parsed from a JSON file:

JavaScript  Copy Code

item.cssClass = styles[index].colour;

Getting a reference to an item

There are various ways to access one or more items present in a Calendar control. The items property of the Schedule returns a collection, containing all the items, currently present in the calendar's schedule. Currently selected items are accessible via the itemSelection property of the Calendar. Particular item or items can be accessed through id by calling schedule’s getItemById method with the id that you have assigned to the Item.