Home Unanswered Active Tags New Question

how to add two row in calendar?

I want to add two row on header of the calendar.

first row contain current date and second row contain no of coloum with dynamic resource coming from database.

Asked by varsha 1 year ago.
Replies

I recommend you to download the trial version of the calendar. It comes with many examples and one of them is how to add resrouces. it's quite simple.

string[] resources = new string[] {"A", "B", "C"};

for (int i = 0; i < 3; i++)
{

Column c = new Column(resources[i], resources[i]);
DayPilotCalendar1.Columns.Add(c);

for (int j = 0; j < 2; j++)
{
DateTime day = first.AddDays(j);

Column subC = new Column(day.ToShortDateString(), resources[i]);
subC.Date = day;
c.Children.Add(subC);
}
}

Comment posted by jjsabe 1 year ago.

thanks,

now its working fine but events are not binding in calendar.

my code is:

private void defineColumns()
{

DayPilotCalendar1.Columns.Clear();
DateTime day = DayPilotCalendar1.StartDate;
Column c = new Column(day.ToShortDateString(), day.ToString("s"));


DayPilotCalendar1.Update(CallBackUpdateType.Full);

c.Date = day;
DayPilotCalendar1.Columns.Add(c);


foreach (DataRow dr in dt.Rows)
{
Column c1 = new Column((string)dr["name"], dr["name"].ToString());
c1.Date = day;
c.Children.Add(c1);

}

}

when i click on navigater events are not bind in calendar.


Comment posted by varsha 1 year ago.

If the Navigator clicks don't update the Calendar, you need to check if you are handling Command event properly and doing the actual update for e.Command == "navigate".

Example:

protected void DayPilotCalendar1_Command(object sender, CommandEventArgs e)
{
  switch (e.Command)
  {
    case "navigate":
      DateTime start = (DateTime) e.Data["start"];
      DayPilotCalendar1.StartDate = start;
      DayPilotCalendar1.DataBind();
      DayPilotCalendar1.Update();
      break;
    // other custom commands handled here
  }
}

You also need to check whether the Value of the bottom-most Column (the deepest child) matches the Resource value of the Event (value of column defined using DataResourceField).

Comment posted by Dan Letecky 1 year ago.
New Reply
This reply is
Your name (optional):

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