RadDatePicker DisabledDayStyle problem

4 posts, 0 answers
  1. Kishan Gandikota
    Kishan Gandikota avatar
    44 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2011 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kishan Gandikota
    Kishan Gandikota avatar
    44 posts
    Member since:
    Sep 2009

    Posted 11 Aug 2011 Link to this post

    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

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 16 Aug 2011 Link to this post

    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.

Back to Top