Class TDataGridColumn

Description

TDataGridColumn class

TDataGridColumn serves as the base class for the different column types of the TDataGrid control. TDataGridColumn defines the properties and methods that are common among all datagrid column types. In particular, it initializes header and footer cells according to HeaderText and HeaderStyle FooterText and FooterStyle properties. If HeaderImageUrl is specified, the image will be displayed instead in the header cell. The ItemStyle is applied to cells that belong to non-header and -footer datagrid items.

When the datagrid enables sorting, if the SortExpression is not empty, the header cell will display a button (linkbutton or imagebutton) that will bubble the sort command event to the datagrid.

The following datagrid column types are provided by the framework currently,

  • TBoundColumn, associated with a specific field in datasource and displays the corresponding data.
  • TEditCommandColumn, displaying edit/update/cancel command buttons
  • TButtonColumn, displaying generic command buttons that may be bound to specific field in datasource.
  • THyperLinkColumn, displaying a hyperlink that may be bound to specific field in datasource.
  • TCheckBoxColumn, displaying a checkbox that may be bound to specific field in datasource.
  • TTemplateColumn, displaying content based on templates.
To create your own column class, simply override initializeCell() method, which is the major logic for managing the data and presentation of cells in the column.

  • abstract:
  • since: 3.0
  • version: $Id: TDataGridColumn.php 1490 2006-11-04 03:33:00Z xue $
  • author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/UI/WebControls/TDataGridColumn.php (line 52)

TComponent
   |
   --TApplicationComponent
      |
      --TDataGridColumn
Direct descendents
Class Description
TBoundColumn TBoundColumn class
TButtonColumn TButtonColumn class
TCheckBoxColumn TCheckBoxColumn class
TDropDownListColumn TDropDownListColumn class
TEditCommandColumn TEditCommandColumn class
THyperLinkColumn THyperLinkColumn class
TLiteralColumn TLiteralColumn class
TTemplateColumn TTemplateColumn class
Method Summary
string formatDataValue (string $formatString, mixed $value)
mixed getDataFieldValue (mixed $data, string $field)
TTableItemStyle getFooterStyle ([boolean $createStyle = true])
string getFooterText ()
string getHeaderImageUrl ()
TTableItemStyle getHeaderStyle ([boolean $createStyle = true])
string getHeaderText ()
string getID ()
TTableItemStyle getItemStyle ([boolean $createStyle = true])
string getSortExpression ()
mixed getViewState (string $key, [mixed $defaultValue = null])
boolean getVisible ([mixed $checkParents = true])
void initialize ()
void initializeCell (TTableCell $cell, integer $columnIndex, string $itemType)
void loadState (mixed $state)
mixed saveState ()
void setFooterText (string $value)
void setHeaderImageUrl (string $value)
void setHeaderText (string $value)
void setID (string $value)
void setOwner (TDataGrid $value)
void setSortExpression (string $value)
void setViewState (string $key, mixed $value, [mixed $defaultValue = null])
void setVisible (boolean $value)
Methods
formatDataValue (line 367)

Formats the text value according to a format string.

If the format string is empty, the original value is converted into a string and returned. If the format string starts with '#', the string is treated as a PHP expression within which the token '{0}' is translated with the data value to be formated. Otherwise, the format string and the data value are passed as the first and second parameters in http://www.php.net/sprintf.

  • return: the formatted result
  • access: protected
string formatDataValue (string $formatString, mixed $value)
  • string $formatString: format string
  • mixed $value: the data to be formatted
getDataFieldValue (line 285)

Fetches the value of the data at the specified field.

If the data is an array, the field is used as an array key. If the data is an of TMap, TList or their derived class, the field is used as a key value. If the data is a component, the field is used as the name of a property.

  • return: data value at the specified field
  • access: protected
  • throws: TInvalidDataValueException if the data or the field is invalid.
mixed getDataFieldValue (mixed $data, string $field)
  • mixed $data: data containing the field of value
  • string $field: the data field
getFooterStyle (line 146)
  • return: the style for footer
  • access: public
TTableItemStyle getFooterStyle ([boolean $createStyle = true])
  • boolean $createStyle: whether to create a style if previously not existing
getFooterText (line 129)
  • return: the text to be displayed in the footer of this column
  • access: public
string getFooterText ()
getHeaderImageUrl (line 99)
  • return: the url of the image to be displayed in header
  • access: public
string getHeaderImageUrl ()
getHeaderStyle (line 116)
  • return: the style for header
  • access: public
TTableItemStyle getHeaderStyle ([boolean $createStyle = true])
  • boolean $createStyle: whether to create a style if previously not existing
getHeaderText (line 83)
  • return: the text to be displayed in the header of this column
  • access: public
string getHeaderText ()
getID (line 61)
  • return: the ID of the column.
  • access: public
string getID ()
getItemStyle (line 160)
  • return: the style for item
  • access: public
TTableItemStyle getItemStyle ([boolean $createStyle = true])
  • boolean $createStyle: whether to create a style if previously not existing
getOwner (line 251)
  • return: datagrid that owns this column
  • access: public
TDataGrid getOwner ()
getSortExpression (line 173)
  • return: the name of the field or expression for sorting
  • access: public
string getSortExpression ()
getViewState (line 209)

Returns a viewstate value.

  • return: the viewstate value corresponding to $key
  • access: protected
mixed getViewState (string $key, [mixed $defaultValue = null])
  • string $key: the name of the viewstate value to be returned
  • mixed $defaultValue: the default value. If $key is not found in viewstate, $defaultValue will be returned
getVisible (line 189)
  • return: whether the column is visible. Defaults to true.
  • access: public
boolean getVisible ([mixed $checkParents = true])
initialize (line 270)

Initializes the column.

This method is invoked by TDataGrid when the column is about to be used to initialize datagrid items. Derived classes may override this method to do additional initialization.

  • access: public
void initialize ()
initializeCell (line 302)

Initializes the specified cell to its initial values.

The default implementation sets the content of header and footer cells. If sorting is enabled by the grid and sort expression is specified in the column, the header cell will show a link/image button. Otherwise, the header/footer cell will only show static text/image. This method can be overriden to provide customized intialization to column cells.

  • access: public
void initializeCell (TTableCell $cell, integer $columnIndex, string $itemType)
  • TTableCell $cell: the cell to be initialized.
  • integer $columnIndex: the index to the Columns property that the cell resides in.
  • string $itemType: the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)

Redefined in descendants as:
loadState (line 234)

Loads persistent state values.

  • access: public
void loadState (mixed $state)
  • mixed $state: state values

Redefined in descendants as:
saveState (line 243)

Saves persistent state values.

  • return: values to be saved
  • access: public
mixed saveState ()

Redefined in descendants as:
setFooterText (line 137)
  • access: public
void setFooterText (string $value)
  • string $value: text to be displayed in the footer of this column
setHeaderImageUrl (line 107)
  • access: public
void setHeaderImageUrl (string $value)
  • string $value: the url of the image to be displayed in header
setHeaderText (line 91)
  • access: public
void setHeaderText (string $value)
  • string $value: text to be displayed in the header of this column
setID (line 73)

Sets the ID of the column.

By explicitly specifying the column ID, one can access the column by $templateControl->ColumnID.

  • access: public
  • throws: TInvalidDataValueException if the ID is of bad format
void setID (string $value)
  • string $value: the ID of the column.
setOwner (line 259)
  • access: public
void setOwner (TDataGrid $value)
  • TDataGrid $value: datagrid object that owns this column
setSortExpression (line 181)
  • access: public
void setSortExpression (string $value)
  • string $value: the name of the field or expression for sorting
setViewState (line 222)

Sets a viewstate value.

Make sure that the viewstate value must be serializable and unserializable.

  • access: protected
void setViewState (string $key, mixed $value, [mixed $defaultValue = null])
  • string $key: the name of the viewstate value
  • mixed $value: the viewstate value to be set
  • mixed $defaultValue: default value. If $value===$defaultValue, the item will be cleared from the viewstate.
setVisible (line 197)
  • access: public
void setVisible (boolean $value)
  • boolean $value: whether the column is visible

Inherited Methods

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()

Documentation generated on Sun, 14 Jan 2007 21:42:00 -0500 by phpDocumentor 1.3.0RC4