PHP Класс Prado\Web\UI\WebControls\TDataGridColumn

TDataGridColumn serves as the base class for the different column types of the {@link 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 {@link setHeaderText HeaderText} and {@link getHeaderStyle HeaderStyle} {@link setFooterText FooterText} and {@link getFooterStyle FooterStyle} properties. If {@link setHeaderImageUrl HeaderImageUrl} is specified, the image will be displayed instead in the header cell. The {@link getItemStyle ItemStyle} is applied to cells that belong to non-header and -footer datagrid items. When the datagrid enables sorting, if the {@link 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 {@link setHeaderRenderer HeaderRenderer} and {@link 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 {@link TRepeater} and {@link TDataList}. Since v3.1.1, TDataGridColumn has introduced {@link 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 {@link 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 {@link \Prado\IDataRenderer} and obtain its {@link \Prado\IDataRenderer::getData Data} property. The following datagrid column types are provided by the framework currently, - {@link TBoundColumn}, associated with a specific field in datasource and displays the corresponding data. - {@link TEditCommandColumn}, displaying edit/update/cancel command buttons - {@link TDropDownListColumn}, displaying a dropdown list when the item is in edit state - {@link TButtonColumn}, displaying generic command buttons that may be bound to specific field in datasource. - {@link THyperLinkColumn}, displaying a hyperlink that may be bound to specific field in datasource. - {@link TCheckBoxColumn}, displaying a checkbox that may be bound to specific field in datasource. - {@link TTemplateColumn}, displaying content based on templates. To create your own column class, simply override {@link initializeCell()} method, which is the major logic for managing the data and presentation of cells in the column.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends Prado\TApplicationComponent
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
getAllowSorting ( ) : boolean Returns a value indicating whether this column allows sorting.
getEnableCellGrouping ( ) : boolean
getFooterRenderer ( ) : string
getFooterStyle ( $createStyle = true ) : TTableItemStyle
getFooterText ( ) : string
getHeaderImageUrl ( ) : string
getHeaderRenderer ( ) : string
getHeaderStyle ( $createStyle = true ) : TTableItemStyle
getHeaderText ( ) : string
getID ( ) : string
getItemStyle ( $createStyle = true ) : TTableItemStyle
getOwner ( ) : TDataGrid
getSortExpression ( ) : string
getVisible ( $checkParents = true ) : boolean
initialize ( ) Initializes the column.
initializeCell ( $cell, $columnIndex, $itemType ) Initializes the specified cell to its initial values.
loadState ( $state ) Loads persistent state values.
saveState ( ) : mixed Saves persistent state values.
setEnableCellGrouping ( $value )
setFooterRenderer ( $value ) Sets the column footer cell renderer class.
setFooterText ( $value )
setHeaderImageUrl ( $value )
setHeaderRenderer ( $value ) Sets the column header cell renderer class.
setHeaderText ( $value )
setID ( $value ) Sets the ID of the column.
setOwner ( TDataGrid $value )
setSortExpression ( $value )
setVisible ( $value )

Защищенные методы

Метод Описание
formatDataValue ( $formatString, $value ) : string Formats the text value according to a format string.
getDataFieldValue ( $data, $field ) : mixed Fetches the value of the data at the specified field.
getViewState ( $key, $defaultValue = null ) : mixed Returns a viewstate value.
initializeFooterCell ( $cell, $columnIndex ) Initializes the footer cell.
initializeHeaderCell ( $cell, $columnIndex ) Initializes the header cell.
setViewState ( $key, $value, $defaultValue = null ) Sets a viewstate value.

Описание методов

formatDataValue() защищенный Метод

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 {@link sprintf}.
protected formatDataValue ( $formatString, $value ) : string
Результат string the formatted result

getAllowSorting() публичный Метод

The column allows sorting only when {@link getSortExpression SortExpression} is not empty and the datagrid allows sorting.
public getAllowSorting ( ) : boolean
Результат boolean whether this column allows sorting

getDataFieldValue() защищенный Метод

If the data is an array, the field is used as an array key. If the data is an of {@link TMap}, {@link 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.
protected getDataFieldValue ( $data, $field ) : mixed
Результат mixed data value at the specified field

getEnableCellGrouping() публичный Метод

С версии: 3.1.1
public getEnableCellGrouping ( ) : boolean
Результат boolean whether cells having the same content should be grouped together. Defaults to false.

getFooterRenderer() публичный Метод

С версии: 3.1.0
public getFooterRenderer ( ) : string
Результат string the class name for the column footer cell renderer. Defaults to empty, meaning not set.

getFooterStyle() публичный Метод

public getFooterStyle ( $createStyle = true ) : TTableItemStyle
Результат TTableItemStyle the style for footer

getFooterText() публичный Метод

public getFooterText ( ) : string
Результат string the text to be displayed in the footer of this column

getHeaderImageUrl() публичный Метод

public getHeaderImageUrl ( ) : string
Результат string the url of the image to be displayed in header

getHeaderRenderer() публичный Метод

С версии: 3.1.0
public getHeaderRenderer ( ) : string
Результат string the class name for the column header cell renderer. Defaults to empty, meaning not set.

getHeaderStyle() публичный Метод

public getHeaderStyle ( $createStyle = true ) : TTableItemStyle
Результат TTableItemStyle the style for header

getHeaderText() публичный Метод

public getHeaderText ( ) : string
Результат string the text to be displayed in the header of this column

getID() публичный Метод

public getID ( ) : string
Результат string the ID of the column.

getItemStyle() публичный Метод

public getItemStyle ( $createStyle = true ) : TTableItemStyle
Результат TTableItemStyle the style for item

getOwner() публичный Метод

public getOwner ( ) : TDataGrid
Результат TDataGrid datagrid that owns this column

getSortExpression() публичный Метод

public getSortExpression ( ) : string
Результат string the name of the field or expression for sorting

getViewState() защищенный Метод

Returns a viewstate value.
protected getViewState ( $key, $defaultValue = null ) : mixed
Результат mixed the viewstate value corresponding to $key

getVisible() публичный Метод

public getVisible ( $checkParents = true ) : boolean
Результат boolean whether the column is visible. Defaults to true.

initialize() публичный Метод

This method is invoked by {@link TDataGrid} when the column is about to be used to initialize datagrid items. Derived classes may override this method to do additional initialization.
public initialize ( )

initializeCell() публичный Метод

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 initializeCell ( $cell, $columnIndex, $itemType )

initializeFooterCell() защищенный Метод

This method attempts to use {@link getFooterRenderer FooterRenderer} to instantiate the footer cell. If that is not available, it will populate the cell with a text string specified by {@link getFooterImageUrl FooterImageUrl}
protected initializeFooterCell ( $cell, $columnIndex )

initializeHeaderCell() защищенный Метод

This method attempts to use {@link 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 {@link getHeaderImageUrl HeaderImageUrl} and {@link 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.
protected initializeHeaderCell ( $cell, $columnIndex )

loadState() публичный Метод

Loads persistent state values.
public loadState ( $state )

saveState() публичный Метод

Saves persistent state values.
public saveState ( ) : mixed
Результат mixed values to be saved

setEnableCellGrouping() публичный Метод

С версии: 3.1.1
public setEnableCellGrouping ( $value )

setFooterRenderer() публичный Метод

If not empty, the class will be used to instantiate as a child control in the column footer cell. If the class implements {@link \Prado\IDataRenderer}, the Data property will be set as the {@link getFooterText FooterText}.
С версии: 3.1.0
public setFooterRenderer ( $value )

setFooterText() публичный Метод

public setFooterText ( $value )

setHeaderImageUrl() публичный Метод

public setHeaderImageUrl ( $value )

setHeaderRenderer() публичный Метод

If not empty, the class will be used to instantiate as a child control in the column header cell. If the class implements {@link \Prado\IDataRenderer}, the Data property will be set as the {@link getFooterText FooterText}.
С версии: 3.1.0
public setHeaderRenderer ( $value )

setHeaderText() публичный Метод

public setHeaderText ( $value )

setID() публичный Метод

By explicitly specifying the column ID, one can access the column by $templateControl->ColumnID.
public setID ( $value )

setOwner() публичный Метод

public setOwner ( TDataGrid $value )
$value TDataGrid

setSortExpression() публичный Метод

public setSortExpression ( $value )

setViewState() защищенный Метод

Make sure that the viewstate value must be serializable and unserializable.
protected setViewState ( $key, $value, $defaultValue = null )

setVisible() публичный Метод

public setVisible ( $value )