Scheduler: Resources (Rows)

The Scheduler resources (rows) can be created directly in the view or in the controller.

Creating Resources in the View

        <%= Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig {
                BackendUrl = ResolveUrl("~/Scheduler/Backend"),
                Resources = new ResourceCollection {
                    new Resource{Name = "Room A", Id = "A", Expanded = true, Children = new ResourceCollection
                                                                              {
                                                                                  new Resource("Room A.1", "A.1"),
                                                                                  new Resource("Room A.2", "A.2"),
                                                                                  new Resource("Room A.3", "A.3")
                                                                              }},
                    new Resource("Room B", "B"),
                    new Resource("Room C", "C"),
                    new Resource("Room D", "D")
                }
            })%>

Creating Resources in the Backend Controller

The Resources collection should be filled in the OnInit() event handler. This event will be called immediately after the Scheduler is initialized on the client side. It is called only once.

The Resources collection will be persisted during all subsequent callback calls and it is not necessary to rebuild it on every callback.

    public class SchedulerController : Controller
    {
        //
        // GET: /Scheduler/

        public ActionResult Backend()
        {
            return new Dps().CallBack(this);
        }

        class Dps : DayPilotScheduler
        {
            protected override void OnInit(InitArgs e)
            {
                Resources.Add("Room A", "A");
                Resources.Add("Room B", "B");
                Resources.Add("Room C", "C");
                Resources.Add("Room D", "D");
                Resources.Add("Room E", "E");

                UpdateWithMessage("Welcome!", CallBackUpdateType.Full);
            }

            protected override void OnFinish()
            {
                if (UpdateType == CallBackUpdateType.None)
                {
                    return;
                }

                Events = new EventManager().FilteredData(StartDate, StartDate.AddDays(Days)).AsEnumerable();

                DataIdField = "id";
                DataTextField = "name";
                DataStartField = "eventstart";
                DataEndField = "eventend";
                DataResourceField = "resource";
            }
        }
    }

DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java