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

Year view

6 Answers 152 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 17 Jul 2009, 12:59 PM
Hi,

I have a calendar with 4 columns and 3 rows to display a whole year.
Setting focused date to the 1st Jan of the current year brings what I need to show.
A year starting 1.1 - and ending 31st Dez.
My problem - if I use fastnavigation and choose (for an example) Today (or a month) I get a view which shows
12 months beginning with the selected one.
My approach - it should display the year (of the selected date) but again 1st Jan to 31st Dez,
I tried to handle DefaultViewChanged - but the code does nothing more then setting the fast navigation properties.
So what I get is a correct (showing jan to dec) fast navigation.
My calendar still displays 12 calendars starting with the selected month instead of Jan what I need.
Here my code
protected void rcYear_DefaultViewChanged(object sender, Telerik.Web.UI.Calendar.DefaultViewChangedEventArgs e) {  
    DateTime dtSel= e.NewView.ViewStartDate;  
    e.NewView.ViewStartDate = new DateTime(dtSel.Year, 1, 1);  
    e.NewView.ViewEndDate = new DateTime(dtSel.Year, 12, 31);  
    e.NewView.ParentCalendar.CalendarView.ViewStartDate=new DateTime(dtSel.Year, 1, 1);  
    e.NewView.ParentCalendar.CalendarView.ViewEndDate = new DateTime(dtSel.Year, 12, 31);  
    e.NewView.ParentCalendar.FocusedDate = new DateTime(dtSel.Year, 1, 1);  
    rcYear.FocusedDate = new DateTime(dtSel.Year, 1, 1);  
}  
 
I know this a bit too much - but I tried to set everything I could find :)

Regards

Manfred

6 Answers, 1 is accepted

Sort by
0
ManniAT
Top achievements
Rank 2
answered on 17 Jul 2009, 04:01 PM
It turns out that the problem is bigger than I expected.
To make the things easier (even better for my design) I disabled fast navigation setting EnableNavigation and EnableMonthYearFastNavigation to false.
Further I added a RadCombobox with possible year values and in the IndexChanged Event handler I tried the following:
RadCalendar rC = fVEntries.FindControl("rcYear") as RadCalendar;  
rC.CalendarView.ViewStartDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 1, 1);  
rC.FocusedDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 1, 1);  
 
But this does not change anything at all :(

Can please anyone tell me how to change the view to a different year?

Regards

Manfred
0
ManniAT
Top achievements
Rank 2
answered on 17 Jul 2009, 04:15 PM
One more thing.
If I use the calendar outside the FormView the code changes - but it does it a bit "strange".
The header is set correct - but the content is set "later" (next callback).
So I have this code
protected void rcbJahre_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e) {  
    RadCalendar rC = fVEntries.FindControl("rcYear") as RadCalendar;  
    rC.CalendarView.ViewStartDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 1, 1);  
    rC.CalendarView.ViewEndDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 12, 31);  
    rC.FocusedDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 1, 1);  
 
    rcYear.CalendarView.ViewStartDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 1, 1);  
    rcYear.CalendarView.ViewEndDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 12, 31);  
    rcYear.FocusedDate = new DateTime(int.Parse(rcbJahre.SelectedValue), 1, 1);  
 
ajax is set that rcbJahre changes the formview and rcYear.
I've initially set 2009 as year.
Changing the year to 2008 with the combo does nothing in the formview.
BUT - it changes the "Caption" from Jan 2009 - Dez 2009 to Jan 2008 - Dez 2008.
Going back to 2009 changes the headline back to Jan 2009 - Dez 2009 but the 12 calendars show now the months of 2008 :)

Really strange - please help this stops me!!!
And the most bitter thing - I need the change inside the formview - which does nothing (event not the "delayed" thing) at all.

Thanks in advance

Manfred
0
ManniAT
Top achievements
Rank 2
answered on 18 Jul 2009, 08:52 AM
Hi,

I'm one step further.
I had to give up the combobox - I couldn't manage to get the multi view calendar to start always with Jan.
My current solution is to enable fast navigation again.
In the view changed handler I remember the year (from EndDate) and rebind my data.
There I set the FocusedDate to "remembered year" 1.1.
The fact that it did not work in form view is gone - the fix was to change the order of the updated controls in RadAjaxProxy.

Anyhow it would be great to find a way to have a "year view" (12 items multi calendar) always starting with Jan.
Or in other words - a calendar, a combobox with possible years - and when I select a year in the combobox my calendar should change it's year.

By the way - an other thing I learned - the order of the controls on the page is important.
I use tooltips with my calendar - and they did not work correct -- until I place the TTManager AFTER the FormView :)

Regards

Manfred
0
Dimo
Telerik team
answered on 23 Jul 2009, 07:11 AM
Hello Manfred,

The following configuration makes RadCalendar behave as you want it to - year view from Jan 1 to Dec 31:

<%@ Page Language="C#" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<script runat="server"
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!IsPostBack) 
        { 
            RadCalendar1.FocusedDate = new DateTime(DateTime.Now.Year, 1, 1); 
        } 
    } 
     
</script> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>RadControls for ASP.NET AJAX</title> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadCalendar1"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadCalendar1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 
 
<telerik:RadCalendar ID="RadCalendar1" runat="server" 
    AutoPostBack="true" EnableMonthYearFastNavigation="false" 
    MultiViewColumns="4" MultiViewRows="3" /> 
 
</form> 
</body> 
</html> 


Kind regards,
Dimo
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
ManniAT
Top achievements
Rank 2
answered on 23 Jul 2009, 09:55 AM
Hi Dimo,

yes . thats what I got till now.
Now the "open problem". I enable fast navigation - and the user chooses "today" - just to reach the current year fast.
I handle DefaultViewChanged - and I guess there is the problem. My Code:
    protected void rcYear_DefaultViewChanged(object sender, Telerik.Web.UI.Calendar.DefaultViewChangedEventArgs e) {  
            rcYear.FocusedDate = new DateTime(e.NewView.ViewStartDate.Year, 1, 1);  
        } 
This code has no effect - the calendar is displayed July to June.
What do I have to use here to have "full year" again?

Thanks for you help

Manfred
0
Dimo
Telerik team
answered on 23 Jul 2009, 02:09 PM
Hello again,

I inspected the RadCalendar code and I am afraid the requested behavior is not supported if you try to handle it server-side and this will be not easy to fix.

However, a client-side solution exists. Here is a new code library demo, which shows what to do:

http://www.telerik.com/community/code-library/aspnet-ajax/calendar/how-to-use-a-multimonth-radcalendar-to-view-whole-years-only.aspx

Best wishes,
Dimo
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.
Tags
Calendar
Asked by
ManniAT
Top achievements
Rank 2
Answers by
ManniAT
Top achievements
Rank 2
Dimo
Telerik team
Share this question
or