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

RadDatePicker DisabledDayStyle problem

3 Answers 211 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kishan Gandikota
Top achievements
Rank 1
Kishan Gandikota asked on 10 Aug 2011, 09:34 PM
Hi,

I have a simple RadDatePicker for which i add special days on the server side code. I intentionally make couple of days to be IsDisabled - true. On the aspx side, i applied the DisabledDayStyle css. But this class gets applied only for the first time when we load the datetime control. If i check for different months that was kept disabled, this class wasn't getting applied. How can we achieve this?

I know we have to do something on clientevent - ondayrender event but how do i actually capture the element? Let me know how do i proceed on this. I somehow do not want to again check for special days on the client side. Any code example would help.

.ASPX page:
<head runat="server">
    <title></title>
    <style type="text/css">
        .RadCalendar_Default .rcMainTable tr .DisabledClass a
        {
            color: #ebe6ca;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="ScriptManager" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadDatePicker ID="radEffDate" runat="server" MinDate="1900-01-01" Culture="en-US">
            <Calendar runat="server">
                <ClientEvents />
                <DisabledDayStyle CssClass="DisabledClass" />
            </Calendar>
            <DateInput Enabled="false" runat="server">
            </DateInput>
        </telerik:RadDatePicker>
    </div>
    </form>
</body>

.CS
if (!IsPostBack)
            {
                radEffDate.SelectedDate = DateTime.Now;
 
                RadCalendarDay r = new RadCalendarDay();
                r.Date = DateTime.Parse("08/09/2011");
                r.IsSelectable = false;
                r.IsDisabled = true;
                radEffDate.Calendar.SpecialDays.Add(r);
                RadCalendarDay r2 = new RadCalendarDay();
                r2.Date = DateTime.Parse("07/09/2011");
                r2.IsSelectable = false;
                r2.IsDisabled = true;               
                radEffDate.Calendar.SpecialDays.Add(r2);
            }


Regards,
Kishan G K

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Aug 2011, 07:15 AM
Hello Kishan,

I tried the same scenario and it is working as expected. Also I have attached a screenshot of the sample.

CSS:
.RadCalendar_Default .rcMainTable tr .DisabledClass a
        {
            color: #ebe6ca;
        }
aspx:
<telerik:RadDatePicker ID="radEffDate" runat="server" MinDate="1900-01-01" Culture="en-US">
            <Calendar ID="Calendar1" runat="server">
                <ClientEvents />
                <DisabledDayStyle CssClass="DisabledClass" />
            </Calendar>
            <DateInput ID="DateInput1" Enabled="false" runat="server">
            </DateInput>
</telerik:RadDatePicker>

Thanks,
Princy
0
Kishan Gandikota
Top achievements
Rank 1
answered on 11 Aug 2011, 02:21 PM
Hi Princy,

I think you jumped the gun bit too fast.... :)

In my example: i have given special days as 08/09/2011 as 07/09/2011.
So disabling of the date works fine with: 08/09/2011. But if the date spans across different screen in the calender control (like 07/09/2011), it doesn't apply the 'disabledClass' style even though it disables it from selecting.

Telerik team, any thoughts!

Regards,
Kishan G K

0
Maria Ilieva
Telerik team
answered on 16 Aug 2011, 11:54 AM
Hello Kishan,

To disable the required dates for the next/previous months, you should add OnDayRender client-side event handler which is called for every calendar day cell when the calendar is rendered as a result of client-side navigation. This event mimics the server-side DayRender event, giving final control over the output of a specific calendar day cell. This event can be used to apply analogous changes to calendar cells when the user navigates that the server-side event handler applied to the cells in the initial view.
For more information about how to disable calendar days in the calendar component of RadDatePicker, please refer to the following article:
Code Library


Greetings,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Calendar
Asked by
Kishan Gandikota
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kishan Gandikota
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or