search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Problem with custom headers

Asked by LouLou
14 years ago.

Hi. I've a problem using custom headers. It all works perfect untill I change the date selection, then the date header remains the same but all of my events disapear. WHen I click back to the current date all works fine.

My code is


On page load I call
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
defineColumns();

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

private void defineColumns()

{ DayPilotCalendar1.Columns.Clear(); //Clear any cuurrent colums from memory


DateTime first = DayPilot.Utils.Week.FirstDayOfWeek();


string[] resources = new string[] { "1", "1", "1", "1", "1", "1", "1" }; //We only use on column!! therefore each column is "1"
string[] headers = new string[] ("8 till 18", "5 till 14", "7 till 15", "6 till 16", "5 till 17", "0 till 0", "0 till 0" )};


for (int i = 0; i < 7; i++) //iterate from 0 t 6 (7 days)
{
DateTime day = first.AddDays(i);


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

for (int j = 0; j < 1; j++)
{

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

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I am sure it must be something to do wwith this line

DateTime first = DayPilot.Utils.Week.FirstDayOfWeek();
But I cannot get it to work.

Any ideas?
Thanks LL

Comment posted by LouLou
14 years ago.

Got it - I needed to send this call from page load


DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstDayOfWeek();
DateTime dtStartDate = DayPilotCalendar1.StartDate;
defineColumns(iPrinter, dtStartDate);


And from Calendar1_SelectionChanged send this one


DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstDayOfWeek(Calendar1.SelectedDate);
DateTime dtStartDate = DayPilotCalendar1.StartDate;
defineColumns(iPrinter, dtStartDate);

Then from DefineColumns() made simple changes of previous code to

DateTime dtStart = startDate;
DateTime day = dtStart.AddDays(i);


Thanks LL

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