Google Apps Script

Class DatePicker

A date picker widget.

Here is an example of how to use this widget:

 
function doGet() {
   var app = UiApp.createApplication();
   var handler = app.createServerHandler("change");
   var picker = app.createDatePicker().addValueChangeHandler(handler).setId("picker");
   app.add(picker);
   return app;
 }

 function change(eventInfo) {
   var app = UiApp.getActiveApplication();
   app.add(app.createLabel("The value of the date picker changed to " +
       eventInfo.parameter.picker));
    return app;
  }
 

Internally, UiApp widgets are built on top of the Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation directly. You can find the DatePicker documentation here.

Methods

MethodReturn typeBrief description
addStyleDependentName(styleName)DatePickerSets the dependent style name of this DatePicker.
addStyleName(styleName)DatePickerAdds a style name to this DatePicker.
addValueChangeHandler(handler)DatePickerAdd a handler for value change events.
getId()StringReturns the id that has been assigned to this object.
getTag()StringGets the text tag of this DatePicker.
getType()StringGets the type of this object.
setCurrentMonth(date)DatePickerSets the DatePicker to show the given month without selecting a particular date.
setHeight(height)DatePickerSets the height of this DatePicker.
setId(id)DatePickerSets the id of this DatePicker.
setName(name)DatePickerSets the name of the DatePicker, which is how it will be referred to when used in a FormPanel or as a callback element on an event handler.
setPixelSize(width, height)DatePickerSets the size of this DatePicker in pixels.
setSize(width, height)DatePickerSets the size of this DatePicker.
setStyleAttribute(attribute, value)DatePickerSets one of this DatePicker's style attributes to a new value.
setStyleAttributes(attributes)DatePickerSets this DatePicker's style attributes.
setStyleName(styleName)DatePickerSets the style name of this DatePicker.
setStylePrimaryName(styleName)DatePickerSets the primary style name of this DatePicker.
setTag(tag)DatePickerSets the text tag of this DatePicker.
setTitle(title)DatePickerSets the hover title of this DatePicker.
setValue(date)DatePickerSets the date shown by this DatePicker.
setVisible(visible)DatePickerSets whether this DatePicker is visible.
setWidth(width)DatePickerSets the width of this DatePicker.

Detailed documentation

addStyleDependentName(styleName)

Sets the dependent style name of this DatePicker.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

DatePicker — the DatePicker itself, useful for chaining.


addStyleName(styleName)

Adds a style name to this DatePicker.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

DatePicker — the DatePicker itself, useful for chaining.


addValueChangeHandler(handler)

Add a handler for value change events.

Note that you can have multiple handlers for the same event on the same widget. They will be called in the order that they were added to the widget, although ServerHandlers may appear to happen simultaneously.

The handler passes back some information to the server about what happened. This information can be accessed as follows:

 
function doGet() {
   var app = UiApp.createApplication();
   var textBox = app.createTextBox();
   var handler = app.createServerHandler("handlerFunction");
   textBox.addValueChangeHandler(handler);
   app.add(textBox);
   return app;
 }

 function handlerFunction(eventInfo) {
   var parameter = eventInfo.parameter;
   // the type of event, in this case "valueChange".
   var eventType = parameter.eventType;
   // the id of the widget that fired this event.
   var source = parameter.source;
 }
 
In addition, the values of certain widgets can be sent up with the event as well as "callback elements." See the documentation of ServerHandler for more information.

Parameters

NameTypeDescription
handlerHandlerthe handler to execute when the event occurs. This can be a ClientHandler or a ServerHandler.

Return

DatePicker — the DatePicker itself, useful for chaining.


getId()

Returns the id that has been assigned to this object.

This can be used in conjunction with app.getElementById() to retrieve a reference to this object.

Return

String — the id that has been assigned to this object


getTag()

Gets the text tag of this DatePicker.

Return

String — the text tag.


getType()

Gets the type of this object.

Return

String — the object type


setCurrentMonth(date)

Sets the DatePicker to show the given month without selecting a particular date.

Parameters

NameTypeDescription
dateDatethe date containing the month to show. For example, setCurrentMonth(new Date("January 1, 2000")) sets the DatePicker to show January 2000.

Return

DatePicker — the DatePicker itself, useful for chaining.


setHeight(height)

Sets the height of this DatePicker.

Parameters

NameTypeDescription
heightStringthe new height in any CSS unit such as "10px" or "50%".

Return

DatePicker — the DatePicker itself, useful for chaining.


setId(id)

Sets the id of this DatePicker.

Parameters

NameTypeDescription
idStringthe new id, which can be used to retrieve the DatePicker from app.getElementById(id).

Return

DatePicker — the DatePicker itself, useful for chaining.


setName(name)

Sets the name of the DatePicker, which is how it will be referred to when used in a FormPanel or as a callback element on an event handler.

Parameters

NameTypeDescription
nameStringthe new name.

Return

DatePicker — the DatePicker itself, useful for chaining.


setPixelSize(width, height)

Sets the size of this DatePicker in pixels.

Parameters

NameTypeDescription
widthIntegerthe new width in pixels.
heightIntegerthe new height in pixels.

Return

DatePicker — the DatePicker itself, useful for chaining.


setSize(width, height)

Sets the size of this DatePicker.

Parameters

NameTypeDescription
widthStringthe new width in any CSS unit such as "10px" or "50%".
heightStringthe new height in any CSS unit such as "10px" or "50%".

Return

DatePicker — the DatePicker itself, useful for chaining.


setStyleAttribute(attribute, value)

Sets one of this DatePicker's style attributes to a new value. Valid attributes are listed here; the values for each attribute are the same as those available in CSS style sheets.

 
// Change the widget's background to black and text color to green.
 widget.setStyleAttribute("background", "black")
     .setStyleAttribute("color", "green");
 

Parameters

NameTypeDescription
attributeStringthe CSS attribute, in camel-case ("fontSize", not "font-size"), as listed here
valueStringthe CSS value

Return

DatePicker — the DatePicker itself, useful for chaining.


setStyleAttributes(attributes)

Sets this DatePicker's style attributes. This is a convenience method that is equivalent to calling setStyleAttribute with every key/value pair in the attributes object. Valid attributes are listed here; the values for each attribute are the same as those available in CSS style sheets.

 
// Change the widget's background to black and text color to green.
 widget.setStyleAttributes({background: "black", color: "green"});
 

Parameters

NameTypeDescription
attributesObjectan object of key/value pairs for the CSS attributes and values to set; valid attributes are listed here

Return

DatePicker — the DatePicker itself, useful for chaining.


setStyleName(styleName)

Sets the style name of this DatePicker.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

DatePicker — the DatePicker itself, useful for chaining.


setStylePrimaryName(styleName)

Sets the primary style name of this DatePicker.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

DatePicker — the DatePicker itself, useful for chaining.


setTag(tag)

Sets the text tag of this DatePicker.

Parameters

NameTypeDescription
tagStringthe new text tag, which can be anything you wish to store with the widget.

Return

DatePicker — the DatePicker itself, useful for chaining.


setTitle(title)

Sets the hover title of this DatePicker.

Not all browsers will show this.

Parameters

NameTypeDescription
titleStringthe hover title.

Return

DatePicker — the DatePicker itself, useful for chaining.


setValue(date)

Sets the date shown by this DatePicker.

Parameters

NameTypeDescription
dateDatethe new date value.

Return

DatePicker — the DatePicker itself, useful for chaining.


setVisible(visible)

Sets whether this DatePicker is visible.

Parameters

NameTypeDescription
visibleBooleanwhether this DatePicker should be visible or not.

Return

DatePicker — the DatePicker itself, useful for chaining.


setWidth(width)

Sets the width of this DatePicker.

Parameters

NameTypeDescription
widthStringthe new width in any CSS unit such as "10px" or "50%".

Return

DatePicker — the DatePicker itself, useful for chaining.

Deprecated methods

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.