how can disable times on RadTimePicker when use timePicker.set_minDate(date1) or timePicker.set_maxDate(date1);

1 posts, 0 answers
  1. Ahamd
    Ahamd avatar
    1 posts
    Member since:
    Dec 2011

    Posted 20 Dec 2011 Link to this post

    Hi,

    i have RadTimePicker that displays times as attached snapshot (radtimepicker.png). so i need to disable hours based on specific criteria.

    for example i need to disable and grey-out all the times after 6AM and before 12PM, so i used set_minDate and set_maxDate in java script but not grayed-out just give me warning.

    is this possible with radtimepicker to gray-out and disable unallowed times?

    following is example of code:



    ASPX:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeFile="Default2.aspx.cs" Inherits="Default2" %>

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <script type="text/javascript">
         function setAllowedDate(sender, args)
         {
            setMinDate();
            setMaxDate();
         }


         function setMinDate() {
             var timePicker = $find("<%= RadTimePicker1.ClientID %>");
                 var date1 = new Date();
                 date1.setHours(<%=MinTimeAllowed %>, 0, 0, 0);
                 timePicker.set_minDate(date1);
                 
         }

         function setMaxDate() {
             var date1 = new Date();
             date1.setHours(<%=MaxTimeAllowed %>, 0, 0, 0);
             var timePicker = $find("<%= RadTimePicker1.ClientID %>");
            
             timePicker.set_maxDate(date1);
         }

        </script>
        <br />
        <br />
        <br />
        Select time:
        <telerik:RadTimePicker ID="RadTimePicker1" runat="server" ZIndex="30001">
        <ClientEvents OnPopupOpening="setAllowedDate" />
        </telerik:RadTimePicker>
        
    </asp:Content>




    code behind:

    public partial class Default2 : System.Web.UI.Page
    {
        private int m_MinTimeAllowed=0;
        protected int m_MaxTimeAllowed=24;
        protected void Page_Load(object sender, EventArgs e)
        {
            m_MinTimeAllowed=5;
            m_MaxTimeAllowed = 20;


        }

        protected int MinTimeAllowed
        {
            get
            {
                return m_MinTimeAllowed;
            }
        }


        protected int MaxTimeAllowed
        {
            get
            {
                return m_MaxTimeAllowed;
            }
        }
    }




    please this task very urgent.

    Thanks

Back to Top