PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TDataGridColumn

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 setHeaderText HeaderText and getHeaderStyle HeaderStyle setFooterText FooterText and getFooterStyle FooterStyle properties. If setHeaderImageUrl HeaderImageUrl is specified, the image will be displayed instead in the header cell. The getItemStyle ItemStyle is applied to cells that belong to non-header and -footer datagrid items.

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

Since v3.1.0, TDataGridColumn has introduced two new properties setHeaderRenderer HeaderRenderer and setFooterRenderer FooterRenderer which can be used to specify the layout of header and footer column cells. A renderer refers to a control class that is to be instantiated as a control. For more details, see TRepeater and TDataList.

Since v3.1.1, TDataGridColumn has introduced setEnableCellGrouping EnableCellGrouping. If a column has this property set true, consecutive cells having the same content in this column will be grouped into one cell. Note, there are some limitations to cell grouping. We determine the cell content according to the cell's TTableCell::getText Text property. If the text is empty and the cell has some child controls, we will pick up the first control who implements IDataRenderer and obtain its IDataRenderer::getData Data property.

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
  • TDropDownListColumn, displaying a dropdown list when the item is in edit state
  • 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 TDataGridColumn::initializeCell() method, which is the major logic for managing the data and presentation of cells in the column.

TComponent
Extended by TApplicationComponent
Extended by TDataGridColumn

Direct known subclasses

TBoundColumn, TButtonColumn, TCheckBoxColumn, TDropDownListColumn, TEditCommandColumn, THyperLinkColumn, TLiteralColumn, TTemplateColumn

Indirect known subclasses

TActiveBoundColumn, TActiveButtonColumn, TActiveCheckBoxColumn, TActiveDropDownListColumn, TActiveEditCommandColumn, TActiveHyperLinkColumn, TActiveLiteralColumn, TActiveTemplateColumn
Abstract
Package: System\Web\UI\WebControls
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at Web/UI/WebControls/TDataGridColumn.php
Methods summary
public string
# getID( )

Returns

string
the ID of the column.
public
# setID( string $value )

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

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

Parameters

$value
string
the ID of the column.

Throws

TInvalidDataValueException
if the ID is of bad format
public string
# getHeaderText( )

Returns

string
the text to be displayed in the header of this column
public
# setHeaderText( string $value )

Parameters

$value
string
text to be displayed in the header of this column
public string
# getHeaderImageUrl( )

Returns

string
the url of the image to be displayed in header
public
# setHeaderImageUrl( string $value )

Parameters

$value
string
the url of the image to be displayed in header
public string
# getHeaderRenderer( )

Returns

string
the class name for the column header cell renderer. Defaults to empty, meaning not set.

Since

3.1.0
public
# setHeaderRenderer( string $value )

Sets the column header cell renderer class.

Sets the column header cell renderer class.

If not empty, the class will be used to instantiate as a child control in the column header cell. If the class implements IDataRenderer, the Data property will be set as the getFooterText FooterText.

Parameters

$value
string
the renderer class name in namespace format.

Since

3.1.0
public TTableItemStyle
# getHeaderStyle( boolean $createStyle = true )

Parameters

$createStyle
boolean
whether to create a style if previously not existing

Returns

TTableItemStyle
the style for header
public string
# getFooterText( )

Returns

string
the text to be displayed in the footer of this column
public
# setFooterText( string $value )

Parameters

$value
string
text to be displayed in the footer of this column
public string
# getFooterRenderer( )

Returns

string
the class name for the column footer cell renderer. Defaults to empty, meaning not set.

Since

3.1.0
public
# setFooterRenderer( string $value )

Sets the column footer cell renderer class.

Sets the column footer cell renderer class.

If not empty, the class will be used to instantiate as a child control in the column footer cell. If the class implements IDataRenderer, the Data property will be set as the getFooterText FooterText.

Parameters

$value
string
the renderer class name in namespace format.

Since

3.1.0
public TTableItemStyle
# getFooterStyle( boolean $createStyle = true )

Parameters

$createStyle
boolean
whether to create a style if previously not existing

Returns

TTableItemStyle
the style for footer
public TTableItemStyle
# getItemStyle( boolean $createStyle = true )

Parameters

$createStyle
boolean
whether to create a style if previously not existing

Returns

TTableItemStyle
the style for item
public string
# getSortExpression( )

Returns

string
the name of the field or expression for sorting
public
# setSortExpression( string $value )

Parameters

$value
string
the name of the field or expression for sorting
public boolean
# getEnableCellGrouping( )

Returns

boolean
whether cells having the same content should be grouped together. Defaults to false.

Since

3.1.1
public
# setEnableCellGrouping( boolean $value )

Parameters

$value
boolean
whether cells having the same content should be grouped together.

Since

3.1.1
public boolean
# getVisible( mixed $checkParents = true )

Returns

boolean
whether the column is visible. Defaults to true.
public
# setVisible( boolean $value )

Parameters

$value
boolean
whether the column is visible
protected mixed
# getViewState( string $key, mixed $defaultValue = null )

Returns a viewstate value.

Returns a viewstate value.

Parameters

$key
string
the name of the viewstate value to be returned
$defaultValue
mixed
the default value. If $key is not found in viewstate, $defaultValue will be returned

Returns

mixed
the viewstate value corresponding to $key
protected
# setViewState( string $key, mixed $value, mixed $defaultValue = null )

Sets a viewstate value.

Sets a viewstate value.

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

Parameters

$key
string
the name of the viewstate value
$value
mixed
the viewstate value to be set
$defaultValue
mixed
default value. If $value===$defaultValue, the item will be cleared from the viewstate.
public
# loadState( mixed $state )

Loads persistent state values.

Loads persistent state values.

Parameters

$state
mixed
state values
public mixed
# saveState( )

Saves persistent state values.

Saves persistent state values.

Returns

mixed
values to be saved
public TDataGrid
# getOwner( )

Returns

TDataGrid
datagrid that owns this column
public
# setOwner( TDataGrid $value )

Parameters

$value
TDataGrid
datagrid object that owns this column
public
# initialize( )

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.

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.

protected mixed
# getDataFieldValue( mixed $data, string $field )

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.

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.

Parameters

$data
mixed
data containing the field of value
$field
string
the data field

Returns

mixed
data value at the specified field

Throws

TInvalidDataValueException
if the data or the field is invalid.
public
# initializeCell( TTableCell $cell, integer $columnIndex, string $itemType )

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.

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.

Parameters

$cell
TTableCell
the cell to be initialized.
$columnIndex
integer
the index to the Columns property that the cell resides in.
$itemType
string
the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
public boolean
# getAllowSorting( )

Returns a value indicating whether this column allows sorting. The column allows sorting only when getSortExpression SortExpression is not empty and the datagrid allows sorting.

Returns a value indicating whether this column allows sorting. The column allows sorting only when getSortExpression SortExpression is not empty and the datagrid allows sorting.

Returns

boolean
whether this column allows sorting
protected
# initializeHeaderCell( TTableCell $cell, integer $columnIndex )

Initializes the header cell.

Initializes the header cell.

This method attempts to use getHeaderRenderer HeaderRenderer to instantiate the header cell. If that is not available, it will populate the cell with an image or a text string, depending on getHeaderImageUrl HeaderImageUrl and getHeaderText HeaderText property values.

If the column allows sorting, image or text will be created as a button which issues Sort command upon user click.

Parameters

$cell
TTableCell
the cell to be initialized
$columnIndex
integer
the index to the Columns property that the cell resides in.
protected
# initializeFooterCell( TTableCell $cell, integer $columnIndex )

Initializes the footer cell.

Initializes the footer cell.

This method attempts to use getFooterRenderer FooterRenderer to instantiate the footer cell. If that is not available, it will populate the cell with a text string specified by getFooterImageUrl FooterImageUrl

Parameters

$cell
TTableCell
the cell to be initialized
$columnIndex
integer
the index to the Columns property that the cell resides in.
protected string
# formatDataValue( string $formatString, mixed $value )

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 sprintf.

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 sprintf.

Parameters

$formatString
string
format string
$value
mixed
the data to be formatted

Returns

string
the formatted result
Methods inherited from TApplicationComponent
getApplication(), getRequest(), getResponse(), getService(), getSession(), getUser(), publishAsset(), publishFilePath()
Methods inherited from TComponent
__call(), __construct(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO