How to block dates

4 posts, 0 answers
  1. Spartan IV
    Spartan IV avatar
    10 posts
    Member since:
    Sep 2012

    Posted 18 Nov 2010 Link to this post

    I am making a query to a database to get the first date and last date of data for a report. How do I block with a X like the default Silverlight calendar does on Telerik RadCalendar?

    RadCalendar1.BlockedDates = value; <= Not available

    Thanks
  2. George
    Admin
    George avatar
    1332 posts

    Posted 24 Nov 2010 Link to this post

    Hello Alexis,

    If I understand you correctly, you want to disable some days of the RadCalendar. I would suggest you to refer to the following link - http://www.telerik.com/help/silverlight/radcalendar-constraining-selection-and-visible-dates.html.

    I hope this helps.

    Sincerely yours,
    George
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Spartan IV
    Spartan IV avatar
    10 posts
    Member since:
    Sep 2012

    Posted 24 Nov 2010 Link to this post

    Well I found a workaround. I expected if the date is outside the selectable range to be disabled (visually), not unclickable. I want to use to know just by viewing the calendar which dates are available (bold) and which ones are not grayed. It will be nice to have a BlockedDateRange as the default Silverlight calendar does. Don't know why (that is extremely useful).

        public class CustomTemplateSelector : DataTemplateSelector
        {
            public override DataTemplate SelectTemplate(object item, DependencyObject container)
            {
                CalendarButtonContent content = item as CalendarButtonContent;
                if (content != null)
                {
                    var calendar = container.GetVisualParent<RadCalendar>();
                    if(content.Date < calendar.SelectableDateStart || content.Date > calendar.SelectableDateEnd)
                    {
                        content.IsEnabled = false;
                        CalendarButton cb = container as CalendarButton;
                        cb.Opacity = 0.25; //Need a visual cue that the date is disabled.

                    }
                }
                return DefaultTemplate;
            }
            public DataTemplate DefaultTemplate
            {
                get;
                set;
            }
        }

  5. George
    Admin
    George avatar
    1332 posts

    Posted 30 Nov 2010 Link to this post

    Hello Alexis,

    I am glad that the issue you were facing is now resolved. Also, I would suggest you to use DisplayDateStart/End properties of the RadCalendar. This will disable all dates outside the range:

    <telerik:RadCalendar DisplayDate="11/30/2010" DisplayDateEnd="12/20/2010" DisplayDateStart="11/20/2010" />

    I hope this helps. Please do not hesitate to contact us if you have any additional questions.


    Sincerely yours,
    George
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top