RadCalendarDay Customization

5 posts, 0 answers
  1. Andrew Jacks
    Andrew  Jacks avatar
    10 posts
    Member since:
    Oct 2009

    Posted 06 Oct 2009 Link to this post

    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

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Oct 2009 Link to this post

    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.
  3. Andrew Jacks
    Andrew  Jacks avatar
    10 posts
    Member since:
    Oct 2009

    Posted 08 Oct 2009 Link to this post

    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

  4. Heinz
    Heinz avatar
    20 posts
    Member since:
    Mar 2008

    Posted 07 Oct 2011 Link to this post

    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
  5. Heinz
    Heinz avatar
    20 posts
    Member since:
    Mar 2008

    Posted 10 Oct 2011 Link to this post

    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
Back to Top