Skip to content
DayPilot

How to add resources columns to the calendar

Asked by Anonymous
14 years ago.

Hi,

I'm trying to add the columns for the resources into my calendar for one day. I already have the scheduler working on a separate page, with the resources loaded into it. I've tried the same method for the caleendar but there isn't a property of 'DayPilotCalendar.Resources.Add(name, id)' as there is with the scheduler. Am I on the wrong lines here? I've changed the view type property to be resources but I'm guessing I need to load my resources table somewhere in the vb?

thanks
Martyn

Answer posted by Dan Letecky [DayPilot]
14 years ago.

Hi Martyn,

In the Calendar control (http://www.daypilot.org/calendar.html) you need to use Columns property:

DayPilotCalendar.Columns.Add(name, id);

You can also define custom date for each column:

Column c = new Column(name, id);
c.Date = DateTime.Today;
DayPilotCalendar.Columns.Add(c);

And in combination with HeaderLevel, you can define a column hierarchy (an example from http://www.daypilot.org/demo/Calendar/DaysResourcesView.aspx):

    private void defineColumns()
    {
        DayPilotCalendar1.Columns.Clear();

        DateTime first = Week.FirstDayOfWeek(DayPilotCalendar1.StartDate);

        for (int i = 0; i < 7; i++)
        {
            DateTime day = first.AddDays(i);

            Column c = new Column(day.ToShortDateString(), day.ToString("s"));
            c.Date = day;
            DayPilotCalendar1.Columns.Add(c);

            Column c1 = new Column("A", "A");
            c1.Date = day;
            c.Children.Add(c1);

            Column c2 = new Column("B", "B");
            c2.Date = day;
            c.Children.Add(c2);

            if (day.Date == DateTime.Today)
            {
                Column c3 = new Column("C", "C");
                c3.Date = day;
                c.Children.Add(c3);
            }

        }
    }

See also:

Comment posted by Anonymous
14 years ago.

Thanks very much Dan, much appreciated.

This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.