47 Answers, 1 is accepted
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.
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.
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 have an ETA on this? Thanks.
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
The task is logged in our TFS with a proper priority.
Sincerely yours,
Kaloyan
the Telerik team
Sincerely yours,
Kaloyan
the Telerik team
Please let me know when a fix is in place.
Thank you.
You will be notified when a fix is provided.
All the best,
Kaloyan
the Telerik team
We are currently working on the problem resolving.
Best wishes,
Kaloyan
the Telerik team
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
Do the RadControls_for_Silverlight_4_2010_3_1213_TRIAL_hotfix.zip fix this problem ?
Thank you very much.
Mathieu
Yes RadControls_for_Silverlight_4_2010_3_1213_TRIAL_hotfix should contain this fix.
Greetings,
Hristo
the Telerik team
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.
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
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}"
>
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?
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
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?
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
Thanks for finally providing this functionality!
Can you provide us a sample project please ?
Thank you
Mathieu
Find the attached application with the recommended approach.
All the best,
Kaloyan
the Telerik team
Thank you very much. It works.
Mathieu
Thanks
I can confirm that the feature is working with the latest build.
Regards,
Kaloyan
the Telerik team
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
You have to refresh (remove the temple or set a new one) it again in case of dates removing.
Greetings,
Kaloyan
the Telerik team
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
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?
We will check the internal logic of the control. You can use the suggested code for now.
Regards,
Kaloyan
the Telerik team
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
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)
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;
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
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
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
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
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!
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