Download Free Demos

Data Collections

Data collections allow you to load data statically, without making requests to server and without reloading the page.

You may need data collections in different situations:

  • To load data to the scheduler
  • To populate a dropdown list with options
  • To set axis items in Unit or Timeline view

In general, to create a data collection and populate some element with it, you should follow the steps below:

  1. Create a collection of objects. Objects are instances of any class inherited from System.Object (IEnumerable<object>)
  2. Populate the desired element with the collection using the AddOptions() method. It takes the object created on the previous step as a parameter.

Here are code samples of data collections you may use in the situations stated above:

Events data collections

You can use data collections to load events to the scheduler

var items = new List(){
    new { id = "1", text = "first event", start_date = "03.06.2011", end_date = "04.06.2011" },
    new { id = "2", text = "second event", start_date = "05.06.2011", end_date = "06.06.2011" }
};
 
var data = new SchedulerAjaxData(items);

Note, to be correctly processed data items for the controls should have 4 properties:

  • id - (int, string etc.) the event id.
  • start_date - (DateTime or string) the date when an event is scheduled to begin. The default format is "%m/%d/%Y %H:%i".
  • end_date - (DateTime or string) the date when an event is scheduled to be completed. The default format is "%m/%d/%Y %H:%i".
  • text - (string) the text of an event.

See available variations of the format string here.

Data collection in dropdown lists

You can use a data collection to define select options of a dropdown list, e.g. 'select' control.

var select = new LightboxSelect("textColor", "Priority");
var items = new List(){
    new { key = "gray", label = "Low" },
    new { key = "blue", label = "Medium" },
    new { key = "red", label = "High" }
};
select.AddOptions(items);

Note, to be correctly processed data items for the controls should have 2 properties:

  • key - the id of an option
  • label - the text label of an option

Data collections for Timeline view

Y-Axis items in the Timeline view can be specified by a data collection.

var timeline = new TimelineView("timeline_id", "room_id"); // initializes the view
sched.Views.Add(timeline); // adds the view to the scheduler
 
var rooms = new List(){
    new { key = "1", label = "Room 1"},
    new { key = "2", label = "Room 2"}
};
timeline.AddOptions(rooms);

Note, to be correctly processed data items for the controls should have 2 properties:

  • key - the id of an item
  • label - the text label of an item

Data collections for Units view

X-Axis items in the Units view can be specified by a data collection.

var unit = new UnitsView("unit1", "room_id"); // initializes the view
sched.Views.Add(unit); // adds the view to the scheduler
 
var rooms = new List(){
    new { key = "1", label = "Room 1"},
    new { key = "2", label = "Room 2"}
};
unit.AddOptions(rooms);

Note, to be correctly processed data items for the controls should have 2 properties:

  • key - the id of an item
  • label - the text label of an item.

Was this article helpful?

Yes No