RadDateTimePicker

2 posts, 0 answers
  1. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 27 Nov 2013 Link to this post

    Hi guys,

    How can i set different increment setting step for hour field and minute field.

    I mean i would like to increment/decrease one hour when pressing up/down arrows. But i would like to increment/decrease 15 minutes when pressing up/down arrows.

    Thank you for your help.
    Sonia.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Nov 2013 Link to this post

    Hi Sonia,

    Please have a look into the following code snippet to increase/decrease hour and minute  based on up/down key.

    ASPX:
    <telerik:RadDateTimePicker ID="RadDateTimePicker" runat="server" onkeydown="key(event);">
        <TimeView TimeFormat="HH:mm" runat="server">
        </TimeView>
    </telerik:RadDateTimePicker>

    JavaScript:
    <script type="text/javascript">
        function key(e) {
            var picker = $find("<%=RadDateTimePicker.ClientID%>");
            //get the selected date and time
            var arr = picker._dateInput.get_value().split(' ');
            var date = $.trim(arr[0]); //date
            var time = $.trim(arr[1]); //time(both hour and minute)
            var temp = time.split(':');
            hr = temp[0]; //hour
            min = temp[1]; //minute
            var am = $.trim(arr[2]);
            if (e.keyCode == 38) {
                //upkey press
                min = parseInt(min) + 15; // minute is incremented by 1
                picker._dateInput.set_value(date + " " + hr + ":" + min + ":" + " " + am);
            }
            else if (e.keyCode == 40) {
                //down keypress
                min = parseInt(min) - 15; // minute is decremented by 1
                picker._dateInput.set_value(date + " " + hr + ":" + min + ":" + " " + am);
            }
        }
    </script>

    Thanks,
    Princy. 
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top