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

RadCalendar.FocusedDate doesn't work correct

4 Answers 106 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Nikolay
Top achievements
Rank 1
Nikolay asked on 13 Jul 2011, 11:17 AM
Hello.

I have problem when I use RadCalendar.FocusedDate on server-side. This method doesn't navigate to focused date.
I think it set focused date to right date, but calendar stay at previous focused date. And when I try to navigate next or previous month(using "<" or ">"), it seems that focused date set to right value, but why calendar don't navigate to this date after setting RadCalendar.FocusedDate???
At server-side there isn't function to navigate to date like client-side navigateToDate()?

Javascript:
 
    function CalendarViewChanging(sender) {
        var baseName = sender.id.substr(0, sender.id.lastIndexOf("_") + 1);
        var calendar = $find(baseName.concat("activityCalendar"));
 
        if (sender.id == baseName.concat("btnPrev")) {
            __doPostBack(calendar.get_id().replace(/_/g, '$'), 'n:-1');
        }
        if (sender.id == baseName.concat("btnNext")) {
            __doPostBack(calendar.get_id().replace(/_/g, '$'), 'n:1');
        }       
    }
 
ASPX:
  
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>    
   <asp:Button runat="server" ID="btnPrev" CssClass="btn btn-prev" OnClientClick="CalendarViewChanging(this);return  false;" />
   <telerik:RadCalendar ID="activityCalendar" AutoPostBack="true" CssClass="calendar"
                                                EnableNavigation="false" EnableMonthYearFastNavigation="false" UseColumnHeadersAsSelectors="false"
                                                UseRowHeadersAsSelectors="false" MultiViewColumns="3" MultiViewRows="1" runat="server"
                                                RangeSelectionMode="OnKeyHold" OnSelectionChanged="ActivityCalendar_SelectionChanged">
                                                                                                                                                                                            
   </telerik:RadCalendar>
   <asp:Button runat="server" ID="btnNext" CssClass="btn btn-next" OnClientClick="CalendarViewChanging(this);return false;" />
</ContentTemplate>
</asp:UpdatePanel>
 
ASPX.CS:
 
protected void ActivityCalendar_SelectionChanged(object sender, SelectedDatesEventArgs e)
{           
   RadCalendar calendar = sender as RadCalendar;
 
   if (calendar.RangeSelectionStartDate != calendar.RangeMinDate && calendar.RangeSelectionEndDate !=  calendar.RangeMaxDate)
      {      
      int diffMonths;
      if (calendar.RangeSelectionStartDate.Year == calendar.RangeSelectionEndDate.Year)
      {
         diffMonths = calendar.RangeSelectionEndDate.Month - calendar.RangeSelectionStartDate.Month;
      }
      else
      {
         diffMonths = calendar.RangeSelectionEndDate.Month + 12 - calendar.RangeSelectionStartDate.Month;
      }
             
      switch (diffMonths)
      {
      case 0:
         calendar.FocusedDate = calendar.RangeSelectionStartDate.AddMonths(-1);
         break;
      case 1:
         calendar.FocusedDate = calendar.RangeSelectionStartDate;
         break;
      default:
         calendar.FocusedDate = calendar.RangeSelectionStartDate;                   
         break;
      }                
   }
}

Please help me, and tip how to resolve this issue.

Thank you.

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 18 Jul 2011, 02:25 PM
Hello Nikolay,

Please note that  FocusedDate property is used to navigate to specific view of the calendar and not to a specific date. Using this property you could only set the view which the Calendar will render but it does not explicitly set the date as selected.  


Kind regards,
Maria Ilieva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Maria Ilieva
Telerik team
answered on 18 Jul 2011, 02:25 PM
Hello Nikolay,

Please note that  FocusedDate property is used to navigate to specific view of the calendar and not to a specific date. Using this property you could only set the view which the Calendar will render but it does not explicitly set the date as selected.  


Kind regards,
Maria Ilieva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Nikolay
Top achievements
Rank 1
answered on 19 Jul 2011, 04:05 PM
Hello.

But I need to set and navigate to specific view of the calendar on server-side. This property is set specific view, but not navigate to this view.

Is this bug?

And how can I set and NAVIGATE to specific view in calendar on server-side?

Or if there is no answer to this question -> how can I refresh or reload calendar in or after event handler OnSelectionChanged?

Something like this:
        protected void ActivityCalendar_SelectionChanged(object sender, SelectedDatesEventArgs e)
        {
                   -- some operators --
                   calendar.FocusedDate = calendar.RangeSelectionStartDate;
                   calendar.refresh();
        }

Thank you.
0
Maria Ilieva
Telerik team
answered on 22 Jul 2011, 11:14 AM
Hello Nikolay,

Note that FocusedDate could be set on the server only on initial Load and not after postback. Currently the only possibility to navigate to specific view not only onLoad is to use the client-side method.
Excuse us for any inconvenience this may limitation may lead.

Best wishes,
Maria Ilieva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Calendar
Asked by
Nikolay
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Nikolay
Top achievements
Rank 1
Share this question
or