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
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

Méthode 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 )

Méthodes protégées

Méthode 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 méthode

protected createPagedDataSource ( ) : TPagedDataSource
Résultat Prado\Collections\TPagedDataSource creates a paged data source

dataBind() public méthode

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 méthode

public dataSourceViewChanged ( $sender, $param )

determineDataSource() protected méthode

protected determineDataSource ( )

ensureDataBound() protected méthode

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 méthode

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

getAllowPaging() public méthode

public getAllowPaging ( ) : boolean
Résultat boolean whether paging is enabled. Defaults to false.

getCurrentPageIndex() public méthode

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

getDataMember() public méthode

public getDataMember ( )

getDataSource() public méthode

public getDataSource ( ) : Traversable
Résultat Traversable data source object, defaults to null.

getDataSourceID() public méthode

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

getDataSourceView() protected méthode

protected getDataSourceView ( )

getInitialized() protected méthode

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

getIsDataBound() protected méthode

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

getPageCount() public méthode

public getPageCount ( ) : integer
Résultat integer number of pages of data items available

getPageSize() public méthode

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

getRequiresDataBinding() protected méthode

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

getSelectParameters() public méthode

public getSelectParameters ( )

getUsingDataSourceID() protected méthode

protected getUsingDataSourceID ( ) : boolean
Résultat 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 méthode

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

onDataBound() public méthode

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

onDataSourceChanged() public méthode

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

onInit() public méthode

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 méthode

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

pagePreLoad() public méthode

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

performDataBinding() abstract protected méthode

abstract protected performDataBinding ( $data )

setAllowCustomPaging() public méthode

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 méthode

public setAllowPaging ( $value )

setCurrentPageIndex() public méthode

public setCurrentPageIndex ( $value )

setDataMember() public méthode

public setDataMember ( $value )

setDataSource() public méthode

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 méthode

public setDataSourceID ( $value )

setInitialized() protected méthode

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

setIsDataBound() protected méthode

protected setIsDataBound ( $value )

setPageSize() public méthode

public setPageSize ( $value )

setRequiresDataBinding() protected méthode

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 méthode

See also: setAllowCustomPaging
public setVirtualItemCount ( $value )

validateDataSource() protected méthode

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