## 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: $Revision: $ $Date: $
- 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
TEditCommandColumn | TEditCommandColumn class
THyperLinkColumn | THyperLinkColumn 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 ()
TTableItemStyle getItemStyle ([boolean $createStyle = true])
TDataGrid getOwner ()
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 setOwner (TDataGrid $value)
void setSortExpression (string $value)
void setViewState (string $key, mixed $value, [mixed $defaultValue = null])
void setVisible (boolean $value)
Methods
formatDataValue (line 345)

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

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

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

- return: the text to be displayed in the footer of this column
- access: public

string getFooterText ()
getHeaderImageUrl (line 76)

- return: the url of the image to be displayed in header
- access: public

string getHeaderImageUrl ()
getHeaderStyle (line 93)

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

- return: the text to be displayed in the header of this column
- access: public

string getHeaderText ()
getItemStyle (line 137)

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

- return: datagrid that owns this column
- access: public

TDataGrid getOwner ()
getSortExpression (line 150)

- return: the name of the field or expression for sorting
- access: public

string getSortExpression ()
getViewState (line 186)

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

- return: whether the column is visible. Defaults to true.
- access: public

boolean getVisible ([mixed $checkParents = true])
initialize (line 247)

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

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:

- TBoundColumn::initializeCell() : Initializes the specified cell to its initial values.
- TButtonColumn::initializeCell() : Initializes the specified cell to its initial values.
- TCheckBoxColumn::initializeCell() : Initializes the specified cell to its initial values.
- TEditCommandColumn::initializeCell() : Initializes the specified cell to its initial values.
- THyperLinkColumn::initializeCell() : Initializes the specified cell to its initial values.
- TTemplateColumn::initializeCell() : Initializes the specified cell to its initial values.

loadState (line 211)

Loads persistent state values.

- access: public

void loadState (mixed $state)

- mixed $state: state values

saveState (line 220)

Saves persistent state values.

- return: values to be saved
- access: public

mixed saveState ()
setFooterText (line 114)

- access: public

void setFooterText (string $value)

- string $value: text to be displayed in the footer of this column

setHeaderImageUrl (line 84)

- access: public

void setHeaderImageUrl (string $value)

- string $value: the url of the image to be displayed in header

setHeaderText (line 68)

- access: public

void setHeaderText (string $value)

- string $value: text to be displayed in the header of this column

setOwner (line 236)

- access: public

void setOwner (TDataGrid $value)

- TDataGrid $value: datagrid object that owns this column

setSortExpression (line 158)

- access: public

void setSortExpression (string $value)

- string $value: the name of the field or expression for sorting

setViewState (line 199)

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

- 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::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> 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, 04 Jun 2006 18:59:08 -0400 by phpDocumentor 1.3.0RC4