Redraw/refresh RadCalendar?

48 posts, 0 answers
  1. stefanbuchman
    stefanbuchman avatar
    2 posts
    Member since:
    Jul 2006

    Posted 19 Feb 2011 Link to this post

    Hi,

    This seems to work dynamically for adding dates to a calendar, however, it doesn't seem to work to remove dates from the calendar.  If I clear the collection I need to navigate away from the month and back again in order for the calendar to redraw?  Is there another way to do this?

    Thanks,

    Stefan
  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 23 Feb 2011 Link to this post

    Hello Nick,

    You have to refresh (remove the temple or set a new one) it again in case of dates removing.

    Greetings,
    Kaloyan
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
  4. Adam
    Adam avatar
    32 posts
    Member since:
    Sep 2010

    Posted 22 Mar 2011 Link to this post

    This appears to have broken in 2011 Q1 release. Resetting the DayButtonStyleSelector does not redraw the control.
  5. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 28 Mar 2011 Link to this post

    Hi Nick,

    I have tried to reproduce the problem using the latest Q1.2011 build without any problem. Attached is the test project.

    All the best,
    Kaloyan
    the Telerik team
  6. Dumitru Anischevici
    Dumitru Anischevici avatar
    1 posts
    Member since:
    May 2010

    Posted 07 Apr 2011 Link to this post

    Hi,

    I noticed that after you remove an event and reset the selector using this code:

    var styleSelector = calendar.DayButtonStyleSelector;
    calendar.DayButtonStyleSelector = null;
    calendar.DayButtonStyleSelector = styleSelector;

    the SelectStyle method is called only for those days which had unmodified style (no events).

    As a workaround after removing event i used this:
    System.Collections.Generic.IList<Telerik.Windows.Controls.Calendar.CalendarButton> buttons =
         calendar.ChildrenOfType<Telerik.Windows.Controls.Calendar.CalendarButton>();
    foreach (var button in buttons)
    {
         if (button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.Date ||
              button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.WeekNumber ||
              button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.TodayDate)
         {
              button.Style = null;
         }
    }

    and after that reset the StyleSelector and styles got changed as expected.

    Is there another solution?
  7. Kasper Schou
    Kasper Schou avatar
    21 posts
    Member since:
    Jul 2009

    Posted 08 Apr 2011 Link to this post

    Nvm.. :)
  8. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 12 Apr 2011 Link to this post

    Hi Kasper Schou,

    We will check the internal logic of the control. You can use the suggested code for now.

    Regards,
    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
  9. vassili
    vassili avatar
    3 posts
    Member since:
    Sep 2010

    Posted 30 Nov 2011 Link to this post

    hi,
    my point is to apply different styles (mainly background color) to daybutton depending on some management rules.

    Im using the suggested code to reset style and it's working good.

    var styleSelector = calendar.DayButtonStyleSelector;
    calendar.DayButtonStyleSelector = null;
    calendar.DayButtonStyleSelector = styleSelector;


    But it's rather slow, as it reset the global style selector. sometime, i dont need an full refresh.
    Is there a way to reset the style for a selection of days rather than all days?

    thanks u in advance
  10. vassili
    vassili avatar
    3 posts
    Member since:
    Sep 2010

    Posted 30 Nov 2011 Link to this post

    hi,
    my point is to apply different styles (mainly background color) to daybutton depending on some management rules.

    Im using the suggested code to reset style and it's working good.

    var styleSelector = calendar.DayButtonStyleSelector;
    calendar.DayButtonStyleSelector = null;
    calendar.DayButtonStyleSelector = styleSelector;


    But it's rather slow, as it reset the global style selector. sometime, i dont need an full refresh.
    Is there a way to reset the style for a selection of days rather than all days?

    thanks u in advance


    (sorry about the double post, i had errors on first submit but didnt check before resubmit my post)
  11. vassili
    vassili avatar
    3 posts
    Member since:
    Sep 2010

    Posted 30 Nov 2011 Link to this post

    ok i got it.

    using this part of code
    if (button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.Date ||
         button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.WeekNumber ||
         button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.TodayDate)
    {
         button.Style = null;
    }

    you should just change the style on ur button.
    Say i have 2 styles, it becomes like this

    if (button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.Date ||
         button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.WeekNumber ||
         button.ButtonType == Telerik.Windows.Controls.Calendar.CalendarButtonType.TodayDate)
    {
    if
    (button.Style == ((MyDayStyleSelector)calendar.DayButtonStyleSelector).FirstStyle)
        button.Style = ((MyDayStyleSelector)calendar.DayButtonStyleSelector).SecondStyle;
    else
        button.Style = ((MyDayStyleSelector)calendar.DayButtonStyleSelector).FirstStyle;
    }


    and there is no need to use that part anymore
    var styleSelector = calendar.DayButtonStyleSelector;
    calendar.DayButtonStyleSelector = null;
    calendar.DayButtonStyleSelector = styleSelector;
  12. Larissa
    Larissa avatar
    8 posts
    Member since:
    Jan 2012

    Posted 16 Jan 2012 Link to this post

    I need to force redraw the RadCalendar too, but in telerik ASP.NET AJAX. Has it been fixed in ASP.NET AJAX version too?
  13. Manuel Ortiz
    Manuel Ortiz avatar
    68 posts
    Member since:
    Aug 2009

    Posted 19 Apr 2013 Link to this post

    I need this for Telerik RadControls for Ajax as well!! Any news?
  14. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 24 Apr 2013 Link to this post

    Hello Manuel,

    You could log your request in our feedback portal linked below so that other users could vote for it and increase its priority:
    http://feedback.telerik.com/project/108

    Regards,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  15. Steven
    Steven avatar
    10 posts
    Member since:
    Jun 2011

    Posted 15 May 2013 Link to this post

    I also need to force a redraw of the calendar.

    I tried calling calObj.repaint(), but that didn't do anything so then I tried

    calObj._navigateNext();
    calObj._navigatePrev();

    And this worked for me.

    Total hack, but works.

    Rich

    EDIT:

    I found in another post, the "official" hack is:

        calObj._moveToDate(calObj.get_focusedDate(), true);

    http://www.telerik.com/community/forums/aspnet-ajax/calendar/how-to-force-ondayrender.aspx
  16. Alivya
    Alivya avatar
    2 posts
    Member since:
    Aug 2008

    Posted 30 Aug 2013 Link to this post

    I used the attached solution to test the style selector after remove dates. But the date which I remove from the collection not change to normal, still red. What should I do?

    private void CalendarRefresh()
    {
             //eColl.Add(new Event { Date = DateTime.Today });
             //eColl.Add(new Event { Date = DateTime.Today.AddDays(1) });
             //eColl.Add(new Event { Date = DateTime.Today.AddDays(2) });

             eColl.RemoveAt(0);
             eColl.RemoveAt(0);
             eColl.RemoveAt(0);

    calendar.DayButtonStyleSelector = null;
    calendar.DayButtonStyleSelector = this.Resources["EventDayTemplateSelector"] as StyleSelector;
    }

    I used the version 2011.2.920.1040
  17. Ken
    Ken avatar
    104 posts
    Member since:
    Aug 2010

    Posted 12 Oct 2015 in reply to Kaloyan Link to this post

    Bringing this back from the dead. Setting CalendarDayButtonStyle to null then back to a style doesn't work, on either Silverlight or WPF. Is there any alternative solution? (except changing the date to some other date and then back, which might trigger some unwanted events/side effects)

     

    Thanks,

    Adrian

  18. Ken
    Ken avatar
    104 posts
    Member since:
    Aug 2010

    Posted 12 Oct 2015 in reply to Ken Link to this post

    Actually, upon digging further, I was doing it wrong so I think your solution works.

    However I have another problem: I need to be able to highlight specific dates "dynamically", i.e. when the user changes something. I use a behavior which sets the style to null and back, which triggers the style selector. But I don't know how I can get access, from the style selector, to some collection of events to be highlighted on my view model.

    I cannot expose a dependency property on the style selector to bind to, because it doesn't inherit from DependencyObject. In the SelectStyle method I can't figure out a way to get to the data context of the parent (which would be the view model).

    Any suggestions?

    Thanks!

  19. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 15 Oct 2015 Link to this post

    Hello Adrian,

    As the current thread became rather long and different queries has been discussed in it I would suggest you to open a separate forum thread/ support ticket and described the exact scenario you are trying to achieve there. Thus we will be able to better track your specific case and provide the bets solution for your scenario.

    Regards,
    Maria Ilieva
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner