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

keep highligted days format

13 Answers 285 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Magnus Modig
Top achievements
Rank 1
Magnus Modig asked on 21 Jun 2008, 05:45 AM
Hi

I use the dayrender event to make days that have a event associated to have a different background color. The calender is set to autopostback so when I click a highlighted day, I fetch that days event from a database. But when I click the day and the postback occurs the format of the highlited days disapers, it did not help to set  "if not page.ispostback" for the specific dayrender code either. How can I keep my format for the higlighted days that have an event associated to it?

Best Regards 

13 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 23 Jun 2008, 02:40 PM
Hi Magnus,

I suggest that you define Special Days Templates for different types of events as shown in this online demo. And then add the days with events to the Special Days collection of the calendar and assign them appropriate templates.

Find more information on how to add special days dynamically at the bottom of this help topic.
 
Let us know if these directions are helpful.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
James Keller
Top achievements
Rank 1
answered on 14 Jul 2008, 11:10 PM
I having this same problem.  Your example http://www.telerik.com/demos/aspnet/prometheus/Calendar/Examples/Programming/CustomDayCellRendering/DefaultCS.aspx even has this bug.  The server mode calendar colors the day, but as soon as you click/select a day then hover over the colored day it disappears. I've got a 2x2 grid of months displayed. I'm trying to highlight a range of days that I want a user to select from.  Multiselect is an option.  Your option for doing special days only works if you set IsSelectable to false.  Do you have any way of making the colored backgrounds stay colored? I'm using the new 2008 AJax controls. 
0
Iana Tsolova
Telerik team
answered on 15 Jul 2008, 09:27 AM
Hi James Keller,

Unfortunately it is a known issue that calendar cell styles set on DayRender are not applied properly after ajax request when RadCalendar is ajaxified with RadAjax. This is due to the DayRender event fires too late, after RadAjax has already been updated the calendar.

A possible workaround is to ajaxify your calendar via asp UpdatePanel instead of using RadAjax.
Another option is to add your highlighted days to the SpecialDays collection of the calendar on Page_Load for instance.

Let us know how it goes.

Regards,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
James Keller
Top achievements
Rank 1
answered on 15 Jul 2008, 03:25 PM
The normal Ajax Update panel worked perfect so far.  Thanks for your help.
0
bonny
Top achievements
Rank 1
answered on 17 Jul 2008, 05:40 PM
Actually I m getting same kind of problem.
I m using radcalendar and in day render event i m programmatically change the color of dates like 5,10,15 etc of all month of all years so it shows me different color but after that when I move mouse over that dates which r in different color(5,10,15) I lose the color for that dates so its worthless for me could u just help me out soon its very urgent

Thanks
Bonny
0
Iana Tsolova
Telerik team
answered on 18 Jul 2008, 07:50 AM
Hello bonny,

Have you tried ajaxifying your RadCalendar via MS UpdatePanel instead of using RadAjax to check if this helps?
Another option for solving your problem would be using special days templates for your colored days as shown in this online demo.

Give it a spin and let us know how it goes.

Best wishes,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Axel
Top achievements
Rank 2
answered on 13 Aug 2009, 12:24 AM
I am using the .net Updatepanel and have the same problem. My special day selection is lost after I hover over that day. I however found out that this behavior only exists if I set the RadCalendar control to autopostback. If I remove autopostback then selection is undamaged.
But now the plot tickens because I am using MultiViewColumns=3 i.e. displaying 3 months at a time. And here in this forum I found out that autopostback is necessary for navigation to work when using MultiViewColumns. So I have a catch 22 here. If I use autopostback then I loose special day selection after hover, and if I set autopostback to false then I loose navigation.

Is there a way out of this mess?

Thank god I'm still evaluating :-)
thanks
Axel
0
Iana Tsolova
Telerik team
answered on 17 Aug 2009, 12:02 PM
Hello Axel,

Indeed, using UpdatePanel for ajaxifying RadCalendar should not spoil the special days styling. However, could you please try removing any ajax and see if it works properly with regular postbacks?
It would be great if you can send me a sample project illustrating your scenario and setup.

Kind regards,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Axel
Top achievements
Rank 2
answered on 17 Aug 2009, 04:16 PM
Hi Lana

Just to be clear, I am not loosing my special days formatting. I am loosing my special day selection style after hovering over a selected special day.
I tried removing the ajax like you said and just use regular postback but with the same results. No change. The Page does it's postback when I select a special day, but when I hover over that selection the style disappears leaving me with an unselected special day style.

Here is my code:
html

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AbsenceCalendar.ascx.cs" Inherits="hv.Absence.AbsenceCalendar" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<asp:Panel id="UserControlContainer" CssClass="UserControlContainer" runat="server">  
<telerik:RadCalendar ID="RadCalendar1" Runat="server" AutoPostBack="True" 
        CultureInfo="Icelandic (Iceland)" DayNameFormat="Short" WeekendDayStyle-CssClass="WeekendDayStyle"   
        font-names="Arial,Verdana,Tahoma" forecolor="Black" MultiViewColumns="3"   
        Skin="Hay" style="border-color: #ececec"   
        CssClass="RadCalendarMultiView_Hay">  
        <WeekendDayStyle CssClass="WeekendDayStyle" /> 
    </telerik:RadCalendar> 
</asp:Panel> 

codebehind:
On PageLoad
 
                if (!Page.IsPostBack)  
                {  
                    LoadHolidays();  
                      
                } 
       protected void LoadHolidays()  
        {  
            // ling to SQl  
            SystemManagementDataContext smd = new SystemManagementDataContext();  
 
            var rec = smd.GetAllHolidays().ToList();  
 
            int cnt = -1;  
 
            if (rec != null)  
            {  
                RadCalendarDay[] myDays = new RadCalendarDay[rec.Count()];  
                foreach (CalendarHoliday c in rec)  
                {  
                    if (c.holidaydate.HasValue)  
                    {  
                        RadCalendarDay oneDay = new RadCalendarDay();  
                        oneDay.Date = c.holidaydate.Value;  
                        oneDay.ToolTip = c.holidayname;  
                          
                        if (string.IsNullOrEmpty(c.cssclass))  
                            oneDay.ItemStyle.CssClass = "CalendarHolidays";  
                        else  
                            oneDay.ItemStyle.CssClass = c.cssclass;  
                        cnt++;  
                        myDays[cnt] = oneDay;  
                          
                    }  
                } 




0
Iana Tsolova
Telerik team
answered on 18 Aug 2009, 12:20 PM
Hello Axel,

I appreciate your efforts. As the calendar behaves the same way with no ajax, we can at least isolate the issue to the extend that the ajax is not the reason.
I went through your code and I was not able to find there the place you are adding the holiday days to SpecialDays collection of the calendar. Could you please try modifying your code as below and see if it works this way:

protected void LoadHolidays()     
        {     
            // ling to SQl     
            SystemManagementDataContext smd = new SystemManagementDataContext();     
    
            var rec = smd.GetAllHolidays().ToList();     
    
            int cnt = -1;     
    
            if (rec != null)     
            {     
                RadCalendarDay[] myDays = new RadCalendarDay[rec.Count()];     
                foreach (CalendarHoliday c in rec)     
                {     
                    if (c.holidaydate.HasValue)     
                    {     
                        RadCalendarDay oneDay = new RadCalendarDay();     
                        oneDay.Date = c.holidaydate.Value;     
                        oneDay.ToolTip = c.holidayname;     
                             
                        if (string.IsNullOrEmpty(c.cssclass))     
                            oneDay.ItemStyle.CssClass = "CalendarHolidays";     
                        else     
                            oneDay.ItemStyle.CssClass = c.cssclass;     
                        cnt++;     
                        myDays[cnt] = oneDay;     
                        RadCalendar1.SpecialDays.Add(oneDay);        
                    }                         
                }    
 

Let me know how it goes.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Axel
Top achievements
Rank 2
answered on 18 Aug 2009, 04:31 PM
Hi again,

Sorry but I must have dropped these two lines of code that follow right after the loop. I am adding a range, not one by one.

 

if (cnt > 0)  
    RadCalendar1.SpecialDays.AddRange(myDays); 

Thanks to Dimo (Telerik) I solved this issue by removing autopostback and use this clientside thingy instead.
    function CalendarViewChanging(sender, eventArgs) {  
        var step = eventArgs.get_step();  
        if (step < 0)  
            __doPostBack("<%= RadCalendar1.UniqueID %>", "n:-1");  
        else  
            __doPostBack("<%= RadCalendar1.UniqueID %>", "n:1");  
    }  
     

See also post #186810
0
Iana Tsolova
Telerik team
answered on 20 Aug 2009, 09:32 AM
Hi Axel,

I modified my code according to the latest provided information but still am not able to replicate the issue with the mouse hover. Could you please try it and let me know how it works on your end and if I missed something from your logic out?

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Brown
Top achievements
Rank 1
answered on 11 Jan 2011, 02:35 AM
Hi Magnus,

 I need small doubt to get the holidays from database and to display on the radcalendar.. i have a stored procedure for list of holidays monthly basis..in that radcalendar page.how can i display those holiday values from database.. to on the particular date on the month basis.. tell me how to do this
Tags
Calendar
Asked by
Magnus Modig
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
James Keller
Top achievements
Rank 1
bonny
Top achievements
Rank 1
Axel
Top achievements
Rank 2
Brown
Top achievements
Rank 1
Share this question
or