This is a migrated thread and some comments may be shown as answers.

RadCalendarDay Customization

4 Answers 180 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Andrew Jacks
Top achievements
Rank 1
Andrew Jacks asked on 07 Oct 2009, 01:55 AM
Guys,

I am attempting to customize the way that Special Events are shown on the Calender.

Currently I can change both the Background and Border colors using the following code: -

        private void AddSpecialDay(List<RadCalendarDay> SpecialDays, DateTime Date)
        {
            RadCalendarDay specialDay = new RadCalendarDay();
            specialDay.Date = Date;
            specialDay.ItemStyle.BackColor = Color.Red;       \\ For example - Actual values are from the DB
            specialDay.ItemStyle.BorderColor = Color.Blue;
            specialDay.ItemStyle.ForeColor = Color.Yellow;
            specialDay.ToolTip = "TEST";
            SpecialDays.Add(specialDay);
        }

However I cannot get the ForeColor changes to take effect.

Has anyone any advice on how I can get this to work?

Thanks

Andrew

 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Oct 2009, 07:59 AM
Hi Andrew,

I also tried the same code and found that the ForeColor is not affected when tried from code behind. So, I tried following workaround by applying CSS in order to accomplish the same. Give a try with this.

C#:
 
protected void Button1_Click(object sender, EventArgs e) 
    RadCalendarDay specialDay = new RadCalendarDay(); 
    specialDay.Date = DateTime.Now.Date; // Set the date 
    specialDay.ItemStyle.CssClass = "MyClass";  
    specialDay.ToolTip = "TEST"
    RadCalendar1.SpecialDays.Add(specialDay); 

CSS:
 
<style type="text/css"
.MyClass a 
    color: White !important; 
    background-color: Red !important; 
</style> 

-Shinu.
0
Andrew Jacks
Top achievements
Rank 1
answered on 08 Oct 2009, 11:49 PM
Shinu,

Thanks for the response, however using CSS to change the colour of the date cell is not going to be an option in our application as colours are maintained by the users and held in the database.

I have found way to Fudge the text colour to change by overriding the Render Event and changing the cell text and including the font colour within it as shown in the following code.

        private void RenderEvent(Telerik.Web.UI.Calendar.DayRenderEventArgs eventArgs)
        {

            const string cellformat = "<font style=\"color:{0}\">{1}</font>";

            foreach (RadCalendarDay specialDay in radCalendar.SpecialDays)
            {
                if (specialDay.Date == eventArgs.Day.Date)
                {
                    eventArgs.Cell.Text = String.Format(cellformat, specialDay.ItemStyle.ForeColor, specialDay.Date.Day;               }
            }
        }



Do you know if the bug will be fixed in a future release?

Thanks

Andrew

0
Heinz
Top achievements
Rank 1
answered on 07 Oct 2011, 01:38 PM
ItemStyle.ForeColor in Calendar  doesn't work at any level until today (2011.2 915). 
I would appreciate to set different font color for special days too.


Thanks
Heinz
0
Heinz
Top achievements
Rank 1
answered on 10 Oct 2011, 09:27 PM
Meanwhile I found the solution. It simply works via CSS. e.g. I want some special days mark as not selectable. I do it with
.sDay, .sDay a, .sDay a:hover, .sDay a:link, .sDay a:visited, .rcOutOfRange, .rcOutOfRange span
{   
    text-decoration:none !important;
    color:#efefef !important;
    background-color:White !important;
}

where I set cssClass for special days to "sDay".

Heinz
Tags
Calendar
Asked by
Andrew Jacks
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andrew Jacks
Top achievements
Rank 1
Heinz
Top achievements
Rank 1
Share this question
or