I am trying to interact with the calendar control server side (c#)
I collect a number of dates from a database and alter the styling of these date cells. The dates from the database are "busy" dates.
So far I have managed to modify the background colour and fore colour of these cells but am unable to
1. Disable these dates completely so that they do not respond to a mouse click
2. Stop the hover style appearing when they mouse is hovered
Ideally I would like to:
1. Disable particular dates and set their styles on the server side
2. Set individual styling on particular days (like colour, hover style etc)
I am finding it particularly frustrating that there seems to be no server side ability to iterate through the dates and set individual css properties on an individual basis.
Please could you let me know if what I am trying to achieve is possible?
Thanks in advance.
6 Answers, 1 is accepted
// create calendar day |
RadCalendarDay bookedDay = new RadCalendarDay(RadCalendar1); |
bookedDay.Date = dtBoldDate; |
bookedDay.ItemStyle.Font.Bold = true; |
bookedDay.ItemStyle.CssClass = "BookingNormal"; |
// repeat day only once |
bookedDay.Repeatable = Telerik.Web.UI.Calendar.RecurringEvents.None; |
// add to special days list |
RadCalendar1.SpecialDays.Add(bookedDay); |
I am struggleing I think to find relevent documentation. I am using the following code below to add special days in.
I am calling this in the dayrender event but it seems to be inconsistent. For example using the code below the tooltip is not showing up where as if I set the e.Cell.ToolTip property it does show up. Also styles are differently applied (ie. the style assignment only shows up on a rollover)
Very confusing and there seem to be very few "real world" examples available.
RadCalendarDay
bookedDay = new RadCalendarDay(RadCalendar1);
bookedDay.Date =
new DateTime(e.Day.Date.Year, e.Day.Date.Month, e.Day.Date.Day);
bookedDay.ItemStyle.Font.Bold =
true;
bookedDay.ItemStyle.CssClass =
"BookingNormal";
bookedDay.ToolTip =
"hello";
// repeat day only once
bookedDay.Repeatable = Telerik.Web.UI.Calendar.
RecurringEvents.None;
// add to special days list
RadCalendar1.SpecialDays.Add(bookedDay);
if
(e.Day.IsWeekend){
DayObject.IsSelectable = false;
e.Cell.CssClass =
"MyClassWeekend";
e.Cell.ToolTip =
"Mon-Fri only";
}
RadCalendar1.SpecialDays.Add(DayObject);
I use the above to set style and state specific to day types (ie. weekend, booked, available)
I could find any way of iterating through the days collection of the calendar in the Page_Load event. I would have much preferred to do it this way.
I have now posted a full example of the calendar with .txt file links to the code and aspx files so you can see what I mean.
http://gcdemos.co.uk/caltest.aspx
Two days on this and I'm tearing my hair out :(
Now have it to a stage where I can set all of the styles but when I fast nav to a month and then go back, any dates that have been selected lose their style when the hover event occurs.
Going mad so any help much appreciated.
Thanks.
I have found that by setting
RadCalendar1.SpecialDays.Clear();
It will stop the mouse hover removing the selected days.
This is turn though introduces another bug which is that the setting of IsSelectable=false does not work.
If I check a click event on the client side, even after setting as false on the server, the client picks it up as true.
This does not happen when the .Clear() method is not used.
Very strange and unless I'm doing something very wrong then this is a bug.