Class \Prado\Web\UI\WebControls\TDataGridColumn
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 \Prado\Web\UI\WebControls\setHeaderText and \Prado\Web\UI\WebControls\getHeaderStyle \Prado\Web\UI\WebControls\setFooterText and \Prado\Web\UI\WebControls\getFooterStyle properties. If \Prado\Web\UI\WebControls\setHeaderImageUrl is specified, the image will be displayed instead in the header cell. The \Prado\Web\UI\WebControls\getItemStyle is applied to cells that belong to non-header and -footer datagrid items.
When the datagrid enables sorting, if the \Prado\Web\UI\WebControls\setSortExpression 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 \Prado\Web\UI\WebControls\setHeaderRenderer and \Prado\Web\UI\WebControls\setFooterRenderer 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 \Prado\Web\UI\WebControls\setEnableCellGrouping. 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 \Prado\Web\UI\WebControls\TTableCell::getText 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 \Prado\IDataRenderer::getData 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 initializeCell() method, which is the major logic for managing the data and presentation of cells in the column.
Class hierarchy
Author: Qiang Xue <qiang.xue@gmail.com>Since: 3.0
public
|
getAllowSorting() : bool
Returns a value indicating whether this column allows sorting.
The column allows sorting only when \Prado\Web\UI\WebControls\getSortExpression is not empty and the datagrid allows sorting. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
initialize() : mixed
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. |
public
|
initializeCell(TTableCell $cell, int $columnIndex, string $itemType) : mixed
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. |
public
|
|
public
|
|
public
|
|
public
|
setFooterRenderer(string $value) : mixed
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 \Prado\Web\UI\WebControls\getFooterText. |
public
|
|
public
|
|
public
|
setHeaderRenderer(string $value) : mixed
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 \Prado\Web\UI\WebControls\getFooterText. |
public
|
|
public
|
setID(string $value) : mixed
Sets the ID of the column.
By explicitly specifying the column ID, one can access the column by $templateControl->ColumnID. |
public
|
|
public
|
|
public
|
|
protected
|
formatDataValue(string $formatString, mixed $value) : string
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. |
protected
|
getDataFieldValue(mixed $data, string $field) : mixed
|
protected
|
|
protected
|
initializeCellRendererControl(TTableCell $cell, string $classPath[, mixed $data = null ]) : mixed
Initializes a cell creating a renderer control.
|
protected
|
initializeFooterCell(TTableCell $cell, int $columnIndex) : mixed
Initializes the footer cell.
This method attempts to use \Prado\Web\UI\WebControls\getFooterRenderer to instantiate the footer cell. If that is not available, it will populate the cell with a text string specified by \Prado\Web\UI\WebControls\getFooterImageUrl |
protected
|
initializeHeaderCell(TTableCell $cell, int $columnIndex) : mixed
Initializes the header cell.
This method attempts to use \Prado\Web\UI\WebControls\getHeaderRenderer to instantiate the header cell. If that is not available, it will populate the cell with an image or a text string, depending on \Prado\Web\UI\WebControls\getHeaderImageUrl and \Prado\Web\UI\WebControls\getHeaderText property values. If the column allows sorting, image or text will be created as a button which issues Sort command upon user click. |
protected
|
setViewState(string $key, mixed $value[, null|mixed $defaultValue = null ]) : mixed
Sets a viewstate value.
Make sure that the viewstate value must be serializable and unserializable. |
\Prado\TApplicationComponent::FX_CACHE_FILE, \Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |