## Class TDatePicker

Description

TDatePicker class.

TDatePicker displays a text box for date input purpose. When the text box receives focus, a calendar will pop up and users can pick up from it a date that will be automatically entered into the text box. The format of the date string displayed in the text box is determined by the DateFormat property. Valid formats are the combination of the following tokens,

      Character Format Pattern (en-US)
      -----------------------------------------
      d          day digit
      dd         padded day digit e.g. 01, 02
      M          month digit
      MM         padded month digit
      MMMM       localized month name, e.g. March, April
      yy         2 digit year
      yyyy       4 digit year
      -----------------------------------------

TDatePicker has three Mode to show the date picker popup.

- Basic -- Only shows a text input, focusing on the input shows the date picker.
- Button -- Shows a button next to the text input, clicking on the button shows the date, button text can be by the ButtonText property
- ImageButton -- Shows an image next to the text input, clicking on the image shows the date picker, image source can be change through the ButtonImageUrl property.

The CssClass property can be used to override the css class name for the date picker panel. CalendarStyle property sets the packages styles available. E.g. default.

The InputMode property can be set to "TextBox" or "DropDownList" with default as "TextBox". In <tt>DropDownList</tt> mode, in addition to the popup date picker, three drop down list (day, month and year) are presented to select the date .

The PositionMode property can be set to "Top" or "Bottom" with default as "Bottom". It specifies the position of the calendar popup, relative to the input field.

- since: 3.0
- version: $Id: TDatePicker.php 2624 2009-03-19 21:20:47Z godzilla80@gmx.net $
- author: Wei Zhuo <weizhuo[at]gmail[dot]com>
- author: Carl G. Mathisen <carlgmathisen@gmail.com>

Located in /Web/UI/WebControls/TDatePicker.php (line 72)

    TComponent
       |
       --TApplicationComponent
          |
          --TControl
             |
             --TWebControl
                |
                --TTextBox
                   |
                   --TDatePicker

Direct descendents

Class | Description
--- | ---
TActiveDatePicker | TActiveDatePicker class

Class Constant Summary
SCRIPT_PATH = 'prado/datepicker'
Method Summary
void addAttributesToRender (THtmlWriter $writer)
TDatePickerClientScript createClientScript ()
string getAssetUrl ([string $file = ''])
string getButtonImageUrl ()
string getButtonText ()
string getCalendarStyle ()
TDatePickerClientScript getClientSide ()
array getCulturalOptions ()
string getCulture ()
string getCurrentCulture ()
integer getData ()
string getDate ()
string getDateFormat ()
array getDateFromPostData (string $key, array $values)
string getDatePickerButtonID ()
array getDatePickerOptions ()
array getDropDownDayOptions ()
integer getFirstDayOfWeek ()
integer getFromYear ()
TDatePickerInputMode getInputMode ()
DateTimeFormatInfo getLocalizedCalendarInfo ()
array getLocalizedMonthNames (DateTimeFormatInfo $info)
TDatePickerMode getMode ()
TDatePickerPositionMode getPositionMode ()
boolean getShowCalendar ()
integer getTimeStamp ()
integer getTimeStampFromText ()
integer getUpToYear ()
integer getValidationPropertyValue ()
void hasDayPattern ()
boolean loadPostData (string $key, array $values)
void onPreRender (mixed $param)
string publishCalendarStyle ()
void registerCalendarClientScript ()
void render (THtmlWriter $writer)
THtmlWriter renderButtonDatePicker (mixed $writer)
void renderCalendarDayOptions (THtmlWriter $writer, [mixed $selected = null])
void renderCalendarMonthOptions (THtmlWriter $writer, [mixed $selected = null])
void renderCalendarSelections (THtmlWriter $writer, array $date)
void renderCalendarYearOptions (THtmlWriter $writer, [mixed $selected = null])
void renderDatePickerButtons (mixed $writer)
void renderDropDownListCalendar (mixed $writer)
THtmlWriter renderImageButtonDatePicker (mixed $writer)
void setAutoPostBack (mixed $value)
void setButtonImageUrl (string $value)
void setButtonText (string $value)
void setCalendarStyle (string $value)
void setCulture (string $value)
void setData (integer $value)
void setDate (string $value)
void setDateFormat (string $value)
void setFirstDayOfWeek (integer $value)
void setFromYear (integer $value)
void setInputMode (TDatePickerInputMode $value)
void setMode (TDatePickerMode $value)
void setPositionMode (TDatePickerPositionMode $value)
void setShowCalendar (boolean $value)
void setTimeStamp (float $value)
void setUpToYear (integer $value)
Methods
addAttributesToRender (line 837)

Add the client id to the input textbox, and register the client scripts.

- access: protected

void addAttributesToRender (THtmlWriter $writer)

- THtmlWriter $writer: writer

Redefinition of:

TTextBox::addAttributesToRender()
  Adds attribute name-value pairs to renderer.

createClientScript (line 377)

- return: javascript validator event options.
- access: protected

TDatePickerClientScript createClientScript ()
getAssetUrl (line 814)

- return: date picker asset url.
- access: protected

string getAssetUrl ([string $file = ''])

- string $file: date picker asset file in the self::SCRIPT_PATH directory.

getButtonImageUrl (line 186)

- return: the image url for "Image" UI mode.
- access: public

string getButtonImageUrl ()
getButtonText (line 227)

- return: text for the date picker button. Default is "...".
- access: public

string getButtonText ()
getCalendarStyle (line 202)

- return: current calendar style
- access: public

string getCalendarStyle ()
getClientSide (line 367)

Gets the TDatePickerClientScript to set the TDatePicker event handlers.

The date picker on the client-side supports the following events.

- <tt>OnDateChanged</tt> -- raised when the date is changed.

You can attach custom javascript code to each of these events

- return: javascript validator event options.
- access: public

TDatePickerClientScript getClientSide ()
getCulturalOptions (line 542)

Get javascript localization options, e.g. month and weekday names.

- return: localization options.
- access: protected

array getCulturalOptions ()
getCulture (line 130)

Gets the current culture.

- return: current culture, e.g. en_AU.
- access: public

string getCulture ()
getCurrentCulture (line 558)

- return: the current culture, falls back to application if culture is not set.
- access: protected

string getCurrentCulture ()
getData (line 323)

Returns the timestamp selected by the user.

This method is required by IDataRenderer. It is the same as getTimeStamp().

- return: the timestamp of the TDatePicker control.
- access: public
- since: 3.1.2
- see: TDatePicker::getTimeStamp()

integer getData ()

Redefinition of:

TTextBox::getData()
  Returns the text content of the TTextBox control.

getDate (line 344)

- return: the date string.
- access: public

string getDate ()
getDateFormat (line 95)

- return: the format of the date string
- access: public

string getDateFormat ()
getDateFromPostData (line 483)

Loads date from drop down list data.

- return: the date selected
- access: protected

array getDateFromPostData (string $key, array $values)

- string $key: the key that can be used to retrieve data from the input data collection
- array $values: the input data collection

getDatePickerButtonID (line 771)

Gets the ID for the date picker trigger button.

- return: unique button ID
- access: protected

string getDatePickerButtonID ()
getDatePickerOptions (line 516)

Get javascript date picker options.

- return: date picker client-side options
- access: protected

array getDatePickerOptions ()

Redefined in descendants as:

- TActiveDatePicker::getDatePickerOptions() : Get javascript date picker options.

getDropDownDayOptions (line 689)

- return: list of day options for a drop down list.
- access: protected

array getDropDownDayOptions ()
getFirstDayOfWeek (line 219)

- return: first day of the week
- access: public

integer getFirstDayOfWeek ()
getFromYear (line 251)

- return: date picker starting year, default is -5 years
- access: public

integer getFromYear ()
getInputMode (line 155)

- return: input method of date values. Defaults to TDatePickerInputMode::TextBox.
- access: public

TDatePickerInputMode getInputMode ()
getLocalizedCalendarInfo (line 568)

- return: date time format information for the current culture.
- access: protected

DateTimeFormatInfo getLocalizedCalendarInfo ()
getLocalizedMonthNames (line 728)

Returns the localized month names that depends on the month format pattern.

"MMMM" will return the month names, "MM" or "MMM" return abbr. month names and "M" return month digits.

- return: localized month names.
- access: protected

array getLocalizedMonthNames (DateTimeFormatInfo $info)

- DateTimeFormatInfo $info: localized date format information.

getMode (line 171)

- return: current calendar UI mode.
- access: public

TDatePickerMode getMode ()
getPositionMode (line 283)

- return: current calendar UI position.
- access: public

TDatePickerPositionMode getPositionMode ()
getShowCalendar (line 112)

- return: whether the calendar window should pop up when the control receives focus
- access: public

boolean getShowCalendar ()
getTimeStamp (line 291)

- return: current selected date from the date picker as timestamp, NULL if timestamp is not set previously.
- access: public

integer getTimeStamp ()
getTimeStampFromText (line 641)

Gets the date from the text input using TSimpleDateFormatter

- return: current selected date timestamp
- access: protected

integer getTimeStampFromText ()
getUpToYear (line 267)

- return: date picker ending year, default +10 years
- access: public

integer getUpToYear ()
getValidationPropertyValue (line 387)

Returns the value to be validated.

This methid is required by IValidatable interface.

- return: the interger timestamp if valid, otherwise the original text.
- access: public

integer getValidationPropertyValue ()

Redefinition of:

TTextBox::getValidationPropertyValue()
  Returns the value to be validated.

hasDayPattern (line 609)

- access: protected

void hasDayPattern ()
loadPostData (line 463)

Loads user input data. Override parent implementation, when InputMode is DropDownList call getDateFromPostData to get date data.

This method is primarly used by framework developers.

- return: whether the data of the component has been changed
- access: public

boolean loadPostData (string $key, array $values)

- string $key: the key that can be used to retrieve data from the input data collection
- array $values: the input data collection

Redefinition of:

TTextBox::loadPostData()
  Loads user input data.

onPreRender (line 398)

Publish the date picker Css asset files.

- access: public

void onPreRender (mixed $param)

Redefinition of:

TControl::onPreRender()
  This method is invoked when the control enters 'OnPreRender' stage.

publishCalendarStyle (line 824)

Publish the calendar style Css asset file.

- return: Css file url.
- access: protected

string publishCalendarStyle ()
registerCalendarClientScript (line 848)

Registers the javascript code to initialize the date picker.

- access: protected

void registerCalendarClientScript ()

Redefined in descendants as:

- TActiveDatePicker::registerCalendarClientScript() : Registers the javascript code to initialize the date picker.

render (line 418)

Renders body content.

This method overrides parent implementation by adding additional date picker button if Mode is Button or ImageButton.

- access: public

void render (THtmlWriter $writer)

- THtmlWriter $writer: writer

Redefinition of:

TWebControl::render()
  Renders the control.

renderButtonDatePicker (line 780)

Adds an additional button such that when clicked it shows the date picker.

- return: writer
- access: protected

THtmlWriter renderButtonDatePicker (mixed $writer)
renderCalendarDayOptions (line 673)

Renders the day drop down list options.

- access: protected

void renderCalendarDayOptions (THtmlWriter $writer, [mixed $selected = null])

- THtmlWriter $writer: the writer used for the rendering purpose
- mixed $selected: selected day.

renderCalendarMonthOptions (line 707)

Renders the month drop down list options.

- access: protected

void renderCalendarMonthOptions (THtmlWriter $writer, [mixed $selected = null])

- THtmlWriter $writer: the writer used for the rendering purpose
- mixed $selected: selected month.

renderCalendarSelections (line 621)

Renders the calendar drop down list depending on the DateFormat pattern.

- access: protected

void renderCalendarSelections (THtmlWriter $writer, array $date)

- THtmlWriter $writer: the Html writer to render the drop down lists.
- array $date: the current selected date

renderCalendarYearOptions (line 752)

Renders the year drop down list options.

- access: protected

void renderCalendarYearOptions (THtmlWriter $writer, [mixed $selected = null])

- THtmlWriter $writer: the writer used for the rendering purpose
- mixed $selected: selected year.

renderDatePickerButtons (line 439)

Renders the date picker popup buttons.

- access: protected

void renderDatePickerButtons (mixed $writer)
renderDropDownListCalendar (line 580)

Renders the drop down list date picker.

- access: protected

void renderDropDownListCalendar (mixed $writer)
renderImageButtonDatePicker (line 796)

Adds an additional image button such that when clicked it shows the date picker.

- return: writer
- access: protected

THtmlWriter renderImageButtonDatePicker (mixed $writer)
setAutoPostBack (line 86)

AutoPostBack is not supported.

- access: public

void setAutoPostBack (mixed $value)

Redefinition of:

TTextBox::setAutoPostBack()
  Sets the value indicating if postback automatically.

setButtonImageUrl (line 178)

- access: public

void setButtonImageUrl (string $value)

- string $value: the image url for "Image" UI mode.

setButtonText (line 235)

- access: public

void setButtonText (string $value)

- string $value: text for the date picker button

setCalendarStyle (line 194)

- access: public

void setCalendarStyle (string $value)

- string $value: set the calendar style

setCulture (line 139)

Sets the culture/language for the date picker.

- access: public

void setCulture (string $value)

- string $value: a culture string, e.g. en_AU.

setData (line 336)

Sets the timestamp represented by this control.

This method is required by IDataRenderer. It is the same as setTimeStamp().

- access: public
- since: 3.1.2
- see: TDatePicker::setTimeStamp()

void setData (integer $value)

- integer $value: the timestamp of the TDatePicker control.

Redefinition of:

TTextBox::setData()
  Sets the text content of the TTextBox control.

setDate (line 352)

- access: public

void setDate (string $value)

- string $value: date string

setDateFormat (line 104)

Sets the format of the date string.

- access: public

void setDateFormat (string $value)

- string $value: the format of the date string

setFirstDayOfWeek (line 211)

Set the first day of week, with 0 as Sunday, 1 as Monday, etc.

- access: public

void setFirstDayOfWeek (integer $value)

- integer $value: 0 for Sunday, 1 for Monday, 2 for Tuesday, etc.

setFromYear (line 243)

- access: public

void setFromYear (integer $value)

- integer $value: date picker starting year, default is 2000.

setInputMode (line 147)

- access: public

void setInputMode (TDatePickerInputMode $value)

- TDatePickerInputMode $value: input method of date values

setMode (line 163)

- access: public

void setMode (TDatePickerMode $value)

- TDatePickerMode $value: calendar UI mode

setPositionMode (line 275)

- access: public

void setPositionMode (TDatePickerPositionMode $value)

- TDatePickerPositionMode $value: calendar UI position

setShowCalendar (line 121)

Sets whether to pop up the calendar window when the control receives focus

- access: public

void setShowCalendar (boolean $value)

- boolean $value: whether to show the calendar window

setTimeStamp (line 303)

Sets the date for the date picker using timestamp.

- access: public

void setTimeStamp (float $value)

- float $value: time stamp for the date picker

setUpToYear (line 259)

- access: public

void setUpToYear (integer $value)

- integer $value: date picker ending year, default +10 years

#### Inherited Methods

Inherited From TTextBox

> TTextBox::addAttributesToRender()
> TTextBox::getAutoCompleteType()
> TTextBox::getAutoPostBack()
> TTextBox::getAutoTrim()
> TTextBox::getCausesValidation()
> TTextBox::getClientClassName()
> TTextBox::getColumns()
> TTextBox::getData()
> TTextBox::getDataChanged()
> TTextBox::getEnableClientScript()
> TTextBox::getIsValid()
> TTextBox::getMaxLength()
> TTextBox::getPersistPassword()
> TTextBox::getPostBackOptions()
> TTextBox::getReadOnly()
> TTextBox::getRows()
> TTextBox::getSafeText()
> TTextBox::getSafeTextParser()
> TTextBox::getTagName()
> TTextBox::getText()
> TTextBox::getTextMode()
> TTextBox::getValidationGroup()
> TTextBox::getValidationPropertyValue()
> TTextBox::getWrap()
> TTextBox::loadPostData()
> TTextBox::onTextChanged()
> TTextBox::raisePostDataChangedEvent()
> TTextBox::renderBeginTag()
> TTextBox::renderClientControlScript()
> TTextBox::renderContents()
> TTextBox::setAutoCompleteType()
> TTextBox::setAutoPostBack()
> TTextBox::setAutoTrim()
> TTextBox::setCausesValidation()
> TTextBox::setColumns()
> TTextBox::setData()
> TTextBox::setEnableClientScript()
> TTextBox::setIsValid()
> TTextBox::setMaxLength()
> TTextBox::setPersistPassword()
> TTextBox::setReadOnly()
> TTextBox::setRows()
> TTextBox::setText()
> TTextBox::setTextMode()
> TTextBox::setValidationGroup()
> TTextBox::setWrap()

Inherited From TWebControl

> TWebControl::addAttributesToRender()
> TWebControl::clearStyle()
> TWebControl::copyBaseAttributes()
> TWebControl::createStyle()
> TWebControl::getAccessKey()
> TWebControl::getBackColor()
> TWebControl::getBorderColor()
> TWebControl::getBorderStyle()
> TWebControl::getBorderWidth()
> TWebControl::getCssClass()
> TWebControl::getDisplay()
> TWebControl::getFont()
> TWebControl::getForeColor()
> TWebControl::getHasStyle()
> TWebControl::getHeight()
> TWebControl::getStyle()
> TWebControl::getTabIndex()
> TWebControl::getTagName()
> TWebControl::getToolTip()
> TWebControl::getWidth()
> TWebControl::render()
> TWebControl::renderBeginTag()
> TWebControl::renderContents()
> TWebControl::renderEndTag()
> TWebControl::setAccessKey()
> TWebControl::setBackColor()
> TWebControl::setBorderColor()
> TWebControl::setBorderStyle()
> TWebControl::setBorderWidth()
> TWebControl::setCssClass()
> TWebControl::setDisplay()
> TWebControl::setForeColor()
> TWebControl::setHeight()
> TWebControl::setStyle()
> TWebControl::setTabIndex()
> TWebControl::setToolTip()
> TWebControl::setWidth()

Inherited From TControl

> TControl::__construct()
> TControl::addedControl()
> TControl::addParsedObject()
> TControl::addToPostDataLoader()
> TControl::applyStyleSheetSkin()
> TControl::autoBindProperty()
> TControl::autoDataBindProperties()
> TControl::bindProperty()
> TControl::broadcastEvent()
> TControl::bubbleEvent()
> TControl::clearChildState()
> TControl::clearControlState()
> TControl::clearNamingContainer()
> TControl::clearViewState()
> TControl::convertUniqueIdToClientId()
> TControl::createChildControls()
> TControl::createControlCollection()
> TControl::dataBind()
> TControl::dataBindChildren()
> TControl::dataBindProperties()
> TControl::ensureChildControls()
> TControl::findControl()
> TControl::findControlsByID()
> TControl::findControlsByType()
> TControl::focus()
> TControl::getAdapter()
> TControl::getAllowChildControls()
> TControl::getAttribute()
> TControl::getAttributes()
> TControl::getChildControlsCreated()
> TControl::getClientID()
> TControl::getControls()
> TControl::getControlStage()
> TControl::getControlState()
> TControl::getCustomData()
> TControl::getEnabled()
> TControl::getEnableTheming()
> TControl::getEnableViewState()
> TControl::getHasAdapter()
> TControl::getHasAttributes()
> TControl::getHasChildInitialized()
> TControl::getHasControls()
> TControl::getHasInitialized()
> TControl::getHasLoaded()
> TControl::getHasLoadedPostData()
> TControl::getHasPreRendered()
> TControl::getID()
> TControl::getNamingContainer()
> TControl::getPage()
> TControl::getParent()
> TControl::getRegisteredObject()
> TControl::getSkinID()
> TControl::getSourceTemplateControl()
> TControl::getTemplateControl()
> TControl::getUniqueID()
> TControl::getViewState()
> TControl::getVisible()
> TControl::hasAttribute()
> TControl::initRecursive()
> TControl::isDescendentOf()
> TControl::isObjectRegistered()
> TControl::loadRecursive()
> TControl::loadState()
> TControl::loadStateRecursive()
> TControl::onDataBinding()
> TControl::onInit()
> TControl::onLoad()
> TControl::onPreRender()
> TControl::onUnload()
> TControl::preRenderRecursive()
> TControl::raiseBubbleEvent()
> TControl::registerObject()
> TControl::removeAttribute()
> TControl::removedControl()
> TControl::render()
> TControl::renderChildren()
> TControl::renderControl()
> TControl::saveState()
> TControl::saveStateRecursive()
> TControl::setAdapter()
> TControl::setAttribute()
> TControl::setChildControlsCreated()
> TControl::setControlStage()
> TControl::setControlState()
> TControl::setCustomData()
> TControl::setEnabled()
> TControl::setEnableTheming()
> TControl::setEnableViewState()
> TControl::setID()
> TControl::setPage()
> TControl::setSkinID()
> TControl::setTemplateControl()
> TControl::setViewState()
> TControl::setVisible()
> TControl::trackViewState()
> TControl::traverseChildControls()
> TControl::unbindProperty()
> TControl::unloadRecursive()
> TControl::unregisterObject()
> TControl::__get()

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

Inherited From TComponent

> TComponent::addParsedObject()
> TComponent::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> TComponent::createdOnTemplate()
> TComponent::detachEventHandler()
> TComponent::evaluateExpression()
> TComponent::evaluateStatements()
> TComponent::getEventHandlers()
> TComponent::getSubProperty()
> TComponent::hasEvent()
> TComponent::hasEventHandler()
> TComponent::hasProperty()
> TComponent::raiseEvent()
> TComponent::setSubProperty()
> TComponent::__get()
> TComponent::__set()

Class Constants
SCRIPT_PATH = 'prado/datepicker' (line 77)

Script path relative to the TClientScriptManager::SCRIPT_PATH

#### Inherited Constants

Inherited from TTextBox

> TTextBox::DEFAULT_COLUMNS
> TTextBox::DEFAULT_ROWS

Inherited from TControl

> TControl::AUTOMATIC_ID_PREFIX
> TControl::CLIENT_ID_SEPARATOR
> TControl::CS_CHILD_INITIALIZED
> TControl::CS_CONSTRUCTED
> TControl::CS_INITIALIZED
> TControl::CS_LOADED
> TControl::CS_PRERENDERED
> TControl::CS_STATE_LOADED
> TControl::ID_FORMAT
> TControl::ID_SEPARATOR
> TControl::IS_CHILD_CREATED
> TControl::IS_CREATING_CHILD
> TControl::IS_DISABLE_THEMING
> TControl::IS_DISABLE_VIEWSTATE
> TControl::IS_ID_SET
> TControl::IS_SKIN_APPLIED
> TControl::IS_STYLESHEET_APPLIED
> TControl::RF_ADAPTER
> TControl::RF_AUTO_BINDINGS
> TControl::RF_CHILD_STATE
> TControl::RF_CONTROLS
> TControl::RF_CONTROLSTATE
> TControl::RF_DATA_BINDINGS
> TControl::RF_EVENTS
> TControl::RF_NAMED_CONTROLS
> TControl::RF_NAMED_CONTROLS_ID
> TControl::RF_NAMED_OBJECTS
> TControl::RF_SKIN_ID

Documentation generated on Mon, 22 Feb 2010 12:17:31 +0000 by phpDocumentor 1.3.0RC4