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

Redraw/refresh RadCalendar?

47 Answers 504 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ben Lischner
Top achievements
Rank 1
Ben Lischner asked on 11 Jan 2010, 08:45 PM
I'm wondering if there's an easy way to get the RadCalendar to re-render itself. I'm using a custom DayTemplateSelector to modify the appearance of dates, but the data that drives the appearance of the dates is not static. I need the ability to have the Calendar redraw so that it can re-calcuate its appearance when I update the underlying data that drives the formatting.

47 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 14 Jan 2010, 09:40 AM
Hi Ben Lischner,

We have a lot of requests for the scenario you are asking about. Unfortunately there is no way to accomplish it. We are working on resolving this issue and we will provide a fix in one of the nearest releases of our controls.

Kind regards,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Albert Holt
Top achievements
Rank 1
answered on 26 Jan 2010, 07:04 PM
I am having the same issue.  Tried things like changing the current month and changing it back, but that doesn't work either - only if the user does this through the gui.  Can't understand why there isn't a simple rebind or refresh function?
0
Kaloyan
Telerik team
answered on 29 Jan 2010, 09:01 AM
Hello Albert Holt,

We are aware of the limitation related to this scenario. We are planning to remove the limitation in the Q2 2010 official release. Please accept our apologies if we have caused you any troubles.


Regards,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ken
Top achievements
Rank 1
answered on 31 Aug 2010, 06:32 PM
Any news?
0
Kaloyan
Telerik team
answered on 02 Sep 2010, 09:35 AM
Hello Adrian,

Please accept our deep apologies. We didn't manage to fix the issue as we were developing some more major tasks during the Q2 time frame. Be sure that the task is in our priority list and will be completed very soon in the near future.

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
0
AlinRaul
Top achievements
Rank 1
answered on 04 Oct 2010, 02:48 PM
Hello there,

Do you have an ETA on this? Thanks.
0
Kaloyan
Telerik team
answered on 07 Oct 2010, 08:49 AM
Hi AlinRaul,

We can't  take on an exact estimation of the fix. We will try for the following Q3 release. Please accept our apologies.

Best wishes,
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
0
Ken
Top achievements
Rank 1
answered on 25 Oct 2010, 12:30 PM
Any news guys?
0
Kaloyan
Telerik team
answered on 27 Oct 2010, 08:16 AM
Hi Adrian,

The task is logged in our TFS with a proper priority.

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
0
Kaloyan
Telerik team
answered on 27 Oct 2010, 08:18 AM
Hi Adrian,


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
0
Michael
Top achievements
Rank 1
answered on 03 Nov 2010, 11:51 PM
I have exactly the same problem.
Please let me know when a fix is in place.

Thank you.
0
Kaloyan
Telerik team
answered on 09 Nov 2010, 10:47 AM
Hello Michael,

You will be notified when a fix is provided.

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
0
Adam
Top achievements
Rank 1
answered on 10 Dec 2010, 02:36 PM
Was this fixed in the Q3 release? If not, has anybody implemented a work around? In our case it is the style selector that needs refreshing.
0
Kaloyan
Telerik team
answered on 11 Dec 2010, 10:01 AM
Hi Adam,

We are currently working on the problem resolving.

Best wishes,
Kaloyan
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Hristo
Telerik team
answered on 14 Dec 2010, 03:03 PM
Hello Everyone,

Just want to let you know that this issue is now Fixed and will be available in the next LIB (latest internal build).

All the best,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Forest
Top achievements
Rank 1
answered on 15 Dec 2010, 03:05 PM
Hello

Do the RadControls_for_Silverlight_4_2010_3_1213_TRIAL_hotfix.zip fix this problem ?

Thank you very much.

Mathieu
0
Hristo
Telerik team
answered on 15 Dec 2010, 03:07 PM
Hi Forest,

Yes RadControls_for_Silverlight_4_2010_3_1213_TRIAL_hotfix should contain this fix.

Greetings,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Jeff
Top achievements
Rank 1
answered on 15 Dec 2010, 04:15 PM
If this is fixed, then what is the solution to redraw the Day Buttons?

Are you positive that RadControls_for_Silverlight_4_2010_3_1213_TRIAL_hotfix contains this fix?  The release notes detail no changes to the RadCalendar control at all.
0
Hristo
Telerik team
answered on 15 Dec 2010, 04:29 PM
Hi Jeff,

There is one note that I should mention - there are few properties DayTemplate, DayTemplateSelector, DayButtonStyle and DayButtonStyleSelector. If you set DayTemplate then changes to DayTemplateSelector will not affect the containers. The same goes for DayButtonStyle. As a rule Selectors are applied only if not selectors properties (DayTemplate and DayButtonStyle in this case) are null.

In our themes we have set both DayTemplate and DayButtonStyle properties so changing the selectors will not update the UI. The easiest solution is to set both properties to {x:Null} in XAML and then selector properties will be used and changing them will update the UI.

Also if you want to apply the same template/style the you could just change DayTemplate or DayButtonStyle properties (without using Selector properties at all).

Here is a link to our online help:
http://www.telerik.com/help/silverlight/radcalendar-editing-button.html

Let us know if you need more information.

Greetings,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Jeff
Top achievements
Rank 1
answered on 15 Dec 2010, 08:47 PM
Ok, I under that I must not use both Selectors and selector properties.

I am dynamically updating my custom DayTemplateSelector's Collection from the RadCalendar control itself with days that contain an event.

I've followed the First Look example in the Demo solution.

Here is my XAML code.

<CollectionViewSource x:Key="AvailabilityView" x:Name="AvailabilityList" Filter="AvailabilityList_Filter" Source="{Binding collectionAvailabilityRecords}" />
     
    <Tyler:AvailabilityCollection x:Key="AvailabilityCollection">
    </Tyler:AvailabilityCollection>
     
    <Tyler:AvailabilityDayTemplateSelector x:Key="AvailablityDayTemplateSelector" x:Name="AvailDayTempSel" AvailabilityCollection="{StaticResource AvailabilityCollection}">

<CollectionViewSource x:Key="AvailabilityView" x:Name="AvailabilityList" Filter="AvailabilityList_Filter" Source="{Binding collectionAvailabilityRecords}" />
    
    <Tyler:AvailabilityCollection x:Key="AvailabilityCollection">
    </Tyler:AvailabilityCollection>
    
    <Tyler:AvailabilityDayTemplateSelector x:Key="AvailablityDayTemplateSelector" x:Name="AvailDayTempSel" AvailabilityCollection="{StaticResource AvailabilityCollection}">

Since these DayTemplateSelectors can only be bound to StaticResources, I've created an empty collection to assign to the DayTemplateSelector.

Then in my calling UserControl code behind, I'm accessing the DayTemplate collection directly on the RadCalendar control and adding dates to that collection from my WCF service results.


private void radCalendar1_refreshEventDays()
{     
  ((OfficerScheduling.AvailabilityDayTemplateSelector)(radCalendar1.DayTemplateSelector)).AvailabilityCollection.Clear();
  foreach (Availability a in ((CalendarView) this.DataContext).collectionAvailabilityRecords)
  {
    ((OfficerScheduling.AvailabilityDayTemplateSelector)(radCalendar1.DayTemplateSelector)).AvailabilityCollection.Add(a);
  }
}

Whenever a user makes a change to affect the records being used in the DayTemplate Selector class, the WCF service is called again. In its AsyncCallback, it populates the DataConext.collectionAvailabilityRecords and then calls the radCalendar1_refreshEventDays() function above.

Perhaps I'm not doing things correctly, but it works when the calendar is initially populated and displayed. So, how does this new update to the RadControl help in updating the display when the backing collection of the DayTemplateSelector changes?
0
Hristo
Telerik team
answered on 16 Dec 2010, 09:09 AM
Hi Jeff,

I'm not sure that I understand your case. Could you please open a support ticket and attach a project demonstrating the problem? This way it will be much easier for me to help you.

Kind regards,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Jeff
Top achievements
Rank 1
answered on 16 Dec 2010, 04:24 PM
Ok, I will do so, but I am pretty much doing exactly what everyone else in this thread is doing.

I am using custom DayTemplateSelector class that is being controlled by a collection of dates.

Your demo project uses a static collection, while everyone else here is using a dynamically populated collection.

When new dates are added or removed to this collection, I and everyone else in this thread would like to see the DayTemplates that are being controlled by the DayTemplateSelector class updated when we change the collection of dates for that class.

For example, on the initial draw of RadCalendar, my collection on the DayTemplateSelector are dates A, B, C.  The dates A, B, C are drawn with the special template highlighted in green. The user performs an action on the page that includes the RadCalendar that causes date D to be added to the collection of dates.

Therefore, they would expect to see dates A, B, C, and now D highlighted in green.  But, the calendar doesn't draw this "D" date as green unless the user clicks the forward button away from the date range, and navigates back.  Doing this causes the RadCalendar to redraw the dates and now we see the A, B, C, and D dates as green.  Everyone here is asking for a way to either have the calendar redraw automatically on modification of the DayTemplateSelector's collection or force a redraw of the days without user interaction.

If there was a "solution" to this problem, how do you force the redraw, or how do you setup the collection for the RadCalendar to notice the change in items?
0
Hristo
Telerik team
answered on 17 Dec 2010, 09:18 AM
Hi Jeff,

I think I understand your case. You have custom DayTemplateSelector and at some point you are adding new DataTemplate to a collection in this custom DayTemplateSelector, right?

RadCalendar is not listening for a collection or property change in DataTemplateSelector class (or its inheritors). That is why updating this collection does not redraw RadCalendar. We did not design RadCalendar to support this scenario.

What we fixed was that updating DayTemplate, DayTemplateSelector, DayButtonStyle and DayButtonStyleSelector after calendar is loaded will redraw the calendar. In your case if you update your collection and then set DayTemplateSelector to null and then to the same selector will redraw the calendar.

I hope this helps.

Regards,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Jeff
Top achievements
Rank 1
answered on 17 Dec 2010, 08:53 PM
Excellent!  This bit of detail is just what I needed.  The calendar is redrawing with all dates. 

Thanks for finally providing this functionality! 
0
Forest
Top achievements
Rank 1
answered on 21 Dec 2010, 07:12 PM
Hi

Can you provide us a sample project please ?

Thank you

Mathieu
0
Kaloyan
Telerik team
answered on 27 Dec 2010, 10:48 AM
Hello Ben Lischner,

Find the attached application with the recommended approach.

All the best,
Kaloyan
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Forest
Top achievements
Rank 1
answered on 29 Dec 2010, 05:03 PM
Hello

Thank you very much. It works.

Mathieu
0
Nick
Top achievements
Rank 1
answered on 12 Feb 2011, 12:04 AM
I have tried the attached sample project and when clicking the Add Date button the calendar does not redraw.  The custom day button style selector code is never hit.  I have the same issue as everyone else in that I need to update the dates being displayed based on a dynamic collection.  There doesn't seem to be a way to do this in the Silverlight version of this control.  Can you please test this sample app against the latest build?

Thanks
0
Kaloyan
Telerik team
answered on 16 Feb 2011, 09:16 AM
Hi Nick,

I can confirm that the feature is working with the latest build.

Regards,
Kaloyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
stefanbuchman
Top achievements
Rank 1
answered on 19 Feb 2011, 08:11 AM
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
0
Kaloyan
Telerik team
answered on 23 Feb 2011, 01:36 PM
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!
0
Adam
Top achievements
Rank 1
answered on 22 Mar 2011, 08:53 PM
This appears to have broken in 2011 Q1 release. Resetting the DayButtonStyleSelector does not redraw the control.
0
Kaloyan
Telerik team
answered on 28 Mar 2011, 08:38 AM
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
0
Dumitru Anischevici
Top achievements
Rank 1
answered on 07 Apr 2011, 09:36 AM
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?
0
Kasper Schou
Top achievements
Rank 1
answered on 08 Apr 2011, 11:21 AM
Nvm.. :)
0
Kaloyan
Telerik team
answered on 12 Apr 2011, 01:47 PM
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
0
vassili
Top achievements
Rank 1
answered on 30 Nov 2011, 01:17 PM
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
0
vassili
Top achievements
Rank 1
answered on 30 Nov 2011, 01:18 PM
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)
0
vassili
Top achievements
Rank 1
answered on 30 Nov 2011, 02:16 PM
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;
0
Larissa
Top achievements
Rank 1
answered on 16 Jan 2012, 11:03 AM
I need to force redraw the RadCalendar too, but in telerik ASP.NET AJAX. Has it been fixed in ASP.NET AJAX version too?
0
Manuel Ortiz
Top achievements
Rank 1
answered on 19 Apr 2013, 11:29 PM
I need this for Telerik RadControls for Ajax as well!! Any news?
0
Maria Ilieva
Telerik team
answered on 24 Apr 2013, 08:47 AM
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.
0
Steven
Top achievements
Rank 1
answered on 15 May 2013, 09:00 PM
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
0
Alivya
Top achievements
Rank 1
answered on 30 Aug 2013, 07:27 AM
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
0
Ken
Top achievements
Rank 1
answered on 12 Oct 2015, 06:48 PM

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

0
Ken
Top achievements
Rank 1
answered on 12 Oct 2015, 07:30 PM

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!

0
Maria Ilieva
Telerik team
answered on 15 Oct 2015, 07:56 AM
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
Tags
Calendar
Asked by
Ben Lischner
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Albert Holt
Top achievements
Rank 1
Ken
Top achievements
Rank 1
AlinRaul
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Adam
Top achievements
Rank 1
Hristo
Telerik team
Forest
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
Nick
Top achievements
Rank 1
stefanbuchman
Top achievements
Rank 1
Dumitru Anischevici
Top achievements
Rank 1
Kasper Schou
Top achievements
Rank 1
vassili
Top achievements
Rank 1
Larissa
Top achievements
Rank 1
Manuel Ortiz
Top achievements
Rank 1
Maria Ilieva
Telerik team
Steven
Top achievements
Rank 1
Alivya
Top achievements
Rank 1
Share this question
or