Kasper Schou
Top achievements
Rank 1
Kasper Schou
asked on 08 Apr 2013, 10:31 AM
On the RadCalendar, how do I get the dates that are visible to the user?
I have tried the DisplayDateChanged event, and it does fire, but I canĀ“t figure out what dates are visible.
Thanks
I have tried the DisplayDateChanged event, and it does fire, but I canĀ“t figure out what dates are visible.
Thanks
4 Answers, 1 is accepted
0
Hello,
In the current version of the control there isn't a built-in feature that could be used in order to get the current visible dates in the Calendar but it is easily achievable. All you need to do is in the code behind drill to the CalendarButtons and then access their CalendarButtonContent.
The next code snippet represents a possible approach in getting all the visible CalendarButtons which represent the dates in the Calendar in a button click event:
Hope this is helpful.
Greetings,
Vladi
the Telerik team
In the current version of the control there isn't a built-in feature that could be used in order to get the current visible dates in the Calendar but it is easily achievable. All you need to do is in the code behind drill to the CalendarButtons and then access their CalendarButtonContent.
The next code snippet represents a possible approach in getting all the visible CalendarButtons which represent the dates in the Calendar in a button click event:
private
void
Button_Click_1(
object
sender, RoutedEventArgs e)
{
var calendarButtons =
this
.Calendar.ChildrenOfType<CalendarButton>().Select(bt => bt.DataContext).OfType<CalendarButtonContent>().Where(content => content.ButtonType == CalendarButtonType.Date || content.ButtonType == CalendarButtonType.TodayDate).ToList();
}
Hope this is helpful.
Greetings,
Vladi
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Joshua Obal
Top achievements
Rank 1
answered on 25 Jul 2014, 01:23 PM
Hi Vladi,
I believe that this functionality has changed since you posted this example last year. In the current version it seems to return a different set of buttons, not just the ones that are visible. Is there now a better way to get the visible dates?
Thanks,
Josh
I believe that this functionality has changed since you posted this example last year. In the current version it seems to return a different set of buttons, not just the ones that are visible. Is there now a better way to get the visible dates?
Thanks,
Josh
0
Joshua Obal
Top achievements
Rank 1
answered on 25 Jul 2014, 02:05 PM
I mostly managed to determine which dates are visible by checking each item in the collection:
if ((!button.IsFromCurrentView) || button.IsInAnotherView)
However, this does not include the greyed-out dates that are part of a previous or future month. How do I determine all of the visible dates?
Thanks,
Josh
if ((!button.IsFromCurrentView) || button.IsInAnotherView)
However, this does not include the greyed-out dates that are part of a previous or future month. How do I determine all of the visible dates?
Thanks,
Josh
0
Hello Joshua,
Thanks for your feedback.
It appears that there this is an issue with Calendar - it is generating an additional empty CalendarButton and this is why you have more buttons in the collection. I have logged that in our internal backlog and it will be considered for fixing in one of the future release versions of the controls. Meanwhile what I can suggest you would be to also check if the content.Text is not null in order to get the correct buttons:
Hope this helps. I have also updated your Telerik points for your involvement.
Regards,
Kalin
Telerik
Thanks for your feedback.
It appears that there this is an issue with Calendar - it is generating an additional empty CalendarButton and this is why you have more buttons in the collection. I have logged that in our internal backlog and it will be considered for fixing in one of the future release versions of the controls. Meanwhile what I can suggest you would be to also check if the content.Text is not null in order to get the correct buttons:
var calendarButtons =
this
.Cal.ChildrenOfType<CalendarButton>().Select(bt => bt.DataContext).OfType<CalendarButtonContent>().Where(content => content.ButtonType == CalendarButtonType.Date || (content.ButtonType == CalendarButtonType.TodayDate && content.Text !=
null
)).ToList();
Hope this helps. I have also updated your Telerik points for your involvement.
Regards,
Kalin
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.