PHP Class Prado\Web\UI\WebControls\TDataBoundControl

TDataBoundControl is the based class for controls that need to populate data from data sources. It provides basic properties and methods that allow the derived controls to associate with data sources and retrieve data from them. TBC.... TDataBoundControl is equipped with paging capabilities. By setting {@link setAllowPaging AllowPaging} to true, the input data will be paged and only one page of data is actually populated into the data-bound control. This saves a lot of memory when dealing with larget datasets. To specify the number of data items displayed on each page, set the {@link setPageSize PageSize} property, and to specify which page of data to be displayed, set {@link setCurrentPageIndex CurrentPageIndex}. When the size of the original data is too big to be loaded all in the memory, one can enable custom paging. In custom paging, the total number of data items is specified manually via {@link setVirtualItemCount VirtualItemCount}, and the data source only needs to contain the current page of data. To enable custom paging, set {@link setAllowCustomPaging AllowCustomPaging} to true.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends TWebControl
Datei anzeigen Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
dataBind ( ) Performs databinding.
dataSourceViewChanged ( $sender, $param )
getAllowCustomPaging ( ) : boolean
getAllowPaging ( ) : boolean
getCurrentPageIndex ( ) : integer
getDataMember ( )
getDataSource ( ) : Traversable
getDataSourceID ( ) : string
getPageCount ( ) : integer
getPageSize ( ) : integer
getSelectParameters ( )
getVirtualItemCount ( ) : integer
onDataBound ( $param ) Raises OnDataBound event.
onDataSourceChanged ( ) Sets {@link setRequiresDataBinding RequiresDataBinding} as true if the control is initialized.
onInit ( $param ) Sets page's OnPreLoad event handler as {@link pagePreLoad}.
onPreRender ( $param ) Ensures any pending databind is performed.
pagePreLoad ( $sender, $param ) Sets {@link getInitialized} as true.
setAllowCustomPaging ( $value ) Sets a value indicating whether the custom paging should be enabled.
setAllowPaging ( $value )
setCurrentPageIndex ( $value )
setDataMember ( $value )
setDataSource ( $value ) Sets the data source object associated with the databound control.
setDataSourceID ( $value )
setPageSize ( $value )
setVirtualItemCount ( $value )

Protected Methods

Method Description
createPagedDataSource ( ) : TPagedDataSource
determineDataSource ( )
ensureDataBound ( ) Ensures any pending {@link dataBind} is called.
getDataSourceView ( )
getInitialized ( ) : boolean
getIsDataBound ( ) : boolean
getRequiresDataBinding ( ) : boolean
getUsingDataSourceID ( ) : boolean
performDataBinding ( $data )
setInitialized ( $value ) Sets a value indicating whether the databound control is initialized.
setIsDataBound ( $value )
setRequiresDataBinding ( $value ) Sets a value indicating whether a databind call is required by the data bound control.
validateDataSource ( $value ) : Traversable Validates if the parameter is a valid data source.

Method Details

createPagedDataSource() protected method

protected createPagedDataSource ( ) : TPagedDataSource
return Prado\Collections\TPagedDataSource creates a paged data source

dataBind() public method

This method overrides the parent implementation by calling {@link performSelect} which fetches data from data source and does the actual binding work.
public dataBind ( )

dataSourceViewChanged() public method

public dataSourceViewChanged ( $sender, $param )

determineDataSource() protected method

protected determineDataSource ( )

ensureDataBound() protected method

This method calls {@link dataBind} if the data source is specified by {@link setDataSourceID} or if {@link getRequiresDataBinding RequiresDataBinding} is true.
protected ensureDataBound ( )

getAllowCustomPaging() public method

public getAllowCustomPaging ( ) : boolean
return boolean whether the custom paging is enabled. Defaults to false.

getAllowPaging() public method

public getAllowPaging ( ) : boolean
return boolean whether paging is enabled. Defaults to false.

getCurrentPageIndex() public method

public getCurrentPageIndex ( ) : integer
return integer the zero-based index of the current page. Defaults to 0.

getDataMember() public method

public getDataMember ( )

getDataSource() public method

public getDataSource ( ) : Traversable
return Traversable data source object, defaults to null.

getDataSourceID() public method

public getDataSourceID ( ) : string
return string ID path to the data source control. Defaults to empty.

getDataSourceView() protected method

protected getDataSourceView ( )

getInitialized() protected method

protected getInitialized ( ) : boolean
return boolean whether the databound control has been initialized. By default, the control is initialized after its viewstate has been restored.

getIsDataBound() protected method

protected getIsDataBound ( ) : boolean
return boolean whether databind has been invoked in the previous page request

getPageCount() public method

public getPageCount ( ) : integer
return integer number of pages of data items available

getPageSize() public method

public getPageSize ( ) : integer
return integer the number of data items on each page. Defaults to 10.

getRequiresDataBinding() protected method

protected getRequiresDataBinding ( ) : boolean
return boolean whether a databind call is required (by the data bound control)

getSelectParameters() public method

public getSelectParameters ( )

getUsingDataSourceID() protected method

protected getUsingDataSourceID ( ) : boolean
return boolean if the databound control uses the data source specified by {@link setDataSourceID}, or it uses the data source object specified by {@link setDataSource}.

getVirtualItemCount() public method

See also: setAllowCustomPaging
public getVirtualItemCount ( ) : integer
return integer virtual number of data items in the data source. Defaults to 0.

onDataBound() public method

This method should be invoked after a databind is performed. It is mainly used by framework and component developers.
public onDataBound ( $param )

onDataSourceChanged() public method

This method is invoked when either {@link setDataSource} or {@link setDataSourceID} is changed.
public onDataSourceChanged ( )

onInit() public method

If viewstate is disabled and the current request is a postback, {@link setRequiresDataBinding RequiresDataBinding} will be set true. This method overrides the parent implementation.
public onInit ( $param )

onPreRender() public method

This method overrides the parent implementation.
public onPreRender ( $param )

pagePreLoad() public method

This method is invoked when page raises PreLoad event.
public pagePreLoad ( $sender, $param )

performDataBinding() abstract protected method

abstract protected performDataBinding ( $data )

setAllowCustomPaging() public method

When the pager is in custom paging mode, the {@link setVirtualItemCount VirtualItemCount} property is used to determine the paging, and the data items in the {@link setDataSource DataSource} are considered to be in the current page.
public setAllowCustomPaging ( $value )

setAllowPaging() public method

public setAllowPaging ( $value )

setCurrentPageIndex() public method

public setCurrentPageIndex ( $value )

setDataMember() public method

public setDataMember ( $value )

setDataSource() public method

The data source must implement Traversable interface. If an array is given, it will be converted to xxx. If a string is given, it will be converted to xxx.
public setDataSource ( $value )

setDataSourceID() public method

public setDataSourceID ( $value )

setInitialized() protected method

If initialized, any modification to {@link setDataSource DataSource} or {@link setDataSourceID DataSourceID} will set {@link setRequiresDataBinding RequiresDataBinding} as true.
protected setInitialized ( $value )

setIsDataBound() protected method

protected setIsDataBound ( $value )

setPageSize() public method

public setPageSize ( $value )

setRequiresDataBinding() protected method

If true and the control has been prerendered while it uses the data source specified by {@link setDataSourceID}, a databind call will be called by this method.
protected setRequiresDataBinding ( $value )

setVirtualItemCount() public method

See also: setAllowCustomPaging
public setVirtualItemCount ( $value )

validateDataSource() protected method

If it is a string or an array, it will be converted as a TList object.
protected validateDataSource ( $value ) : Traversable
return Traversable the data that is traversable