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

How to block dates

3 Answers 67 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Spartan IV
Top achievements
Rank 1
Spartan IV asked on 19 Nov 2010, 02:57 AM
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

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 24 Nov 2010, 12:10 PM
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
0
Spartan IV
Top achievements
Rank 1
answered on 24 Nov 2010, 11:24 PM
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;
        }
    }

0
George
Telerik team
answered on 30 Nov 2010, 09:57 AM
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
Tags
Calendar
Asked by
Spartan IV
Top achievements
Rank 1
Answers by
George
Telerik team
Spartan IV
Top achievements
Rank 1
Share this question
or