Ticket T449970
Visible to All Users

dxDateBox - How to set min and max time

created 8 years ago

Hi,

DateTime Box Time picker does not support min and max Time such as 8 AM To 8 PM only.

What is the ideal way of achieving it.

Thanks,
Paritosh

Answers approved by DevExpress Support

created 8 years ago (modified 2 years ago)

Hi Paritosh,

For the "time" picker, set the dxDateBox.min and dxDateBox.max options as shown below:

JavaScript
$("#dateBox").dxDateBox({ value: new Date(2016, 1, 1), type: "time", min: new Date(2016, 1, 1, 8), max: new Date(2016, 1, 1, 20) })

See also:
Date Objects

If you set the dxDateBox.type option to 'datetime', there is no documented API for this scenario. A possible solution is to execute the following code in the dxDateBox.onOpened event handler:

JavaScript
$("#date-time").dxDateBox({ type: "datetime", value: now, onOpened: function(e) { e.component._strategy._timeView._hourBox.option('min', 8); e.component._strategy._timeView._hourBox.option('max', 20); } });

This approach uses undocumented API and we cannot guarantee that it will work properly in future versions. However, we will take your scenario into account for future versions.

Updated:

You can set these variables to nulls - https://jsfiddle.net/ArtemK/7u15mbpL/1/.
I also noticed that the value option cannot be undefined in this scenario, and created a separate ticket on your behalf regarding this issue:
dxDateBox - The min and max settings don't work if the value option is undefined

    Show previous comments (9)
    Alessandro (DevExpress Support) 8 years ago

      Hi,

      I have created a separate ticket on your behalf (T450773: dxDateBox - Validation error is displayed when the editor value is cleared). It has been placed in our processing queue and will be answered shortly.

      PB PB
      paritosh baghel 8 years ago

        Hi,

        Interval value is not getting considered if I open the same url in mobile browser.

        Please find attached screenshot.

        How we can evaluate this product if single widget has so many problem.These are simple use cases which we need as a product.

        Thanks,
        Paritosh

        Alessandro (DevExpress Support) 8 years ago

          Hi,

          Thank you for pointing out this issue. I was able to reproduce it on our side and registered a separate bug report on your behalf at: T451153: dxDateBox - The interval setting has no effect in mobile themes. We will contact you once we fix the issue. Please accept our sincere apologies for the inconvenience.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.