Default selected month/year when DateSelectionMode==Month

4 posts, 0 answers
  1. Chris
    Chris avatar
    2 posts
    Member since:
    Aug 2010

    Posted 20 Aug 2010 Link to this post

    I'm using the RadCalendar in Month selection mode (DateSelectionMode="Month"). I want the control to default to the current month and for this month to be visibly selected by default as well.

    When I default the SelectedDate and/or DisplayDate properties to the current date the current month is still not visibly selected.

    The only way I can get this to work is via a hack like:
    Loaded += (s, e) =>
    {
      var today = DateTime.Today;
      calendar.SelectedDate = new DateTime(today.Year, today.Month, 2);
      calendar.SelectedDate = new DateTime(today.Year, today.Month, 1);
    };

    Is this a bug? Is there a better way to default to the current month?

  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 25 Aug 2010 Link to this post

    Hello Chris,

    This is the only possible way to select a date when onload is presented, as most of the control parts of the RadCalendar are properly loaded.  

    Sincerely yours,
    Kaloyan
    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Chris
    Chris avatar
    2 posts
    Member since:
    Aug 2010

    Posted 26 Aug 2010 Link to this post

    Thanks for your response Kaloyan.

    Perhaps I was not clear enough, but this is not an appropriate long-term solution given our usage of this control.

    The only way to get a default selection to display in "Month" selection mode is to set the SelectedDate to the first day of a given month/year. However, this is not enough, as we also need to set it twice - once to some other day of the month/year (like 2), and then to 1 (as in the example code I provided).

    This is not appropriate as we have bindings to the SelectedDate property which cause events to fire when the value is changed, resulting in long-running operations like database queries. So the required hack to change the SelectedDate twice to get a visual default selection is a big issue for us.

    Surely the visual default selection of the calendar in "Month" mode should be the month/year of the current value of the SelectedDate? Also, it doesn't make sense that the SelectedDate must only be set to the 1st day of a month/year for a default to display.
  5. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 27 Aug 2010 Link to this post

    Hello Chris,

    There is no need to set the SelectedDate twice. Setting the property to the first day of the month will lead you to the desire result. Unfortunately this may be considered as a bug in our implementation of the control.  We will try to fix the issue for the next release.

    All the best,
    Kaloyan
    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
Back to Top