Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

DateTimePicker API

Allows the user to choose date and time.

See controller.rb and index.erb view in the /app/DateTime folder of the System API Samples application for an example.

You can also execute DataTimePicker via AJAX call for set date/time without leaving the page. (Currently implemented for Android, iPhone and Blackberry.) See controller.rb and index.erb view in the /app/DateTimeAJ folder of the System API Samples application for more information about execute Date/Time Picker via AJAX call. This example demonstrates setting date/time without leaving the page.

choose

Opens a window where the user can choose date and time.

DateTimePicker.choose(callback, title, initial_time, fmt, opaque)
callback url to the callback method that is called when the user chooses a date/time and presses OK or Cancel.
title The title of the date/time input window.
initial_time The initial time.
fmt The format of the input field: 0 - full date and time, 1 - date only, 2 - time only.
opaque (optional) callback data (i.e. the state of the form) that you want to preserve so you can re-populate the page with data. For example, if your datetime field in a form is the 3rd out of 5 fields, once the user picks the datetime, you want to re-render the form with fields 1 and 2 still filled in.

choose_with_range

Opens a window where the user can choose date and time from a range.

DateTimePicker.choose_with_range(callback, title, initial_time, fmt, user_data, mindatetime, maxdatetime)
callback url to callback method that is called when the user chooses a date/time and presses OK or Cancel.
title The title of the date/time input field.
initial_time The time.
fmt The format of the input field: 0 - full date and time, 1 - date only, 2 - time only.
user_data (optional) This string is non-interpreted and will be returned in the callback, unmodified.
mindatetime minimum datetime for setup range. Setup to Time.at(0) for no limit.
maxdatetime maximum datetime for setup range. Setup to Time.at(0) for no limit.

set_change_value_callback

(only for iPhone + call DateTimePicker via Ajax call) Set a callback for every change of the date/time value in the DateTimePicker UI control. You can have DateTimePicker and current page on screen together, and you can use the callback to modify date/time value on the page during editing in DateTimePicker control. If you use this method, use it before each call of the choose methods.

DateTimePicker.set_change_value_callback(callback)
callback url to callback method that is called on the change event.

callback method

Once the user chooses a date/time and presses OK or Cancel, the callback URL you specified will be called. The callback is a POST message; the body of the message contains ‘status’, ‘result’, and if provided, ‘user_data’.

The callback method uses the following parameters.

status "ok" or "cancel"
result String. The selected date as the number of seconds since Epoch. Ruby time can be created from it using the Time::at method. No result if status = "cancel".
user_data (optional) the same string that was passed into the choose method.
mindatetime minimum datetime for setup range. Setup to Time.at(0) for no limit.
maxdatetime maximum datetime for setup range. Setup to Time.at(0) for no limit.
Back to Top