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

[Solved] Next month arrow is disabled if Value is less than 1 month from MaxDate

1 Answer 19 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lothar James Foss
Top achievements
Rank 1
Lothar James Foss asked on 10 May 2010, 05:33 PM
I am seeing this problem with MVC 1, using version 2010.1.309 of the controls, however it can also be replicated using your demo page http://demos.telerik.com/aspnet-mvc/Calendar?theme=vista with the following settings:

- show dates between 1/1/1900 and 7/14/2010 
- have pre-selected 6/15/2010

I have so far only tested with IE 8 and Google Chrome.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 May 2010, 12:34 PM
Hello Lothar,

Thank you drawing our attention to this issue. I am glad to inform you that this bug was fixed and the fix will be included in the next release of Telerik Components for ASP.NET MVC.

Here is the code excerpt, which you need to replace in order to fix this issue by yourself. The code is placed in CalendarHtmlBuilder.cs in the Telerik.Web.Mvc project.

[Old]:

public IHtmlNode NavigationTag()
{
    IHtmlNode tag = new HtmlTag("div")
                    .AddClass(UIPrimitives.Header);
 
    DateTime? focusedDate = Calendar.DetermineFocusedDate();
 
    tag.Children.Add(NavigationLink(CalendarNavigation.Prev, focusedDate,
         focusedDate.Value.AddMonths(-1) < Calendar.MinDate ? true : false));
 
    tag.Children.Add(NavigationLink(CalendarNavigation.Fast, focusedDate, false));
 
    tag.Children.Add(NavigationLink(CalendarNavigation.Next, focusedDate,
         focusedDate.Value.AddMonths(1) > Calendar.MaxDate ? true : false));
 
    return tag;
}

[New]:
public IHtmlNode NavigationTag()
{
    IHtmlNode tag = new HtmlTag("div")
                    .AddClass(UIPrimitives.Header);
 
    DateTime? focusedDate = Calendar.DetermineFocusedDate();
 
    tag.Children.Add(NavigationLink(CalendarNavigation.Prev, focusedDate,
        CompareDates(focusedDate, Calendar.MinDate, true) <= 0 ? true : false));
 
    tag.Children.Add(NavigationLink(CalendarNavigation.Fast, focusedDate, false));
 
    tag.Children.Add(NavigationLink(CalendarNavigation.Next, focusedDate,
        CompareDates(focusedDate, Calendar.MaxDate, false) >= 0 ? true : false));
 
    return tag;
}
 
private int CompareDates(DateTime? focusedDate, DateTime? boundaryDate, bool isPrev)
{
    if (!focusedDate.HasValue || !boundaryDate.HasValue)
        return isPrev ? 1 : -1;
 
    DateTime focusedDateValue = focusedDate.Value;
    DateTime boundaryDateValue = boundaryDate.Value;
 
    int result;
    if (focusedDateValue.Year > boundaryDateValue.Year)
    {
        result = 1;
    }
    else if (focusedDateValue.Year < boundaryDateValue.Year)
    {
        result = -1;
    }
    else
    {
        result = focusedDateValue.Month == boundaryDateValue.Month ? 0
               : focusedDateValue.Month > boundaryDateValue.Month ? 1
               : -1;
    }
 
    return result;
}

I have updated your Telerik points.

Regards,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Calendar
Asked by
Lothar James Foss
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or