PHP Class Prado\Web\UI\WebControls\TPager

TPager creates a pager that provides UI for end-users to interactively specify which page of data to be rendered in a {@link TDataBoundControl}-derived control, such as {@link TDataList}, {@link TRepeater}, {@link TCheckBoxList}, etc. The target data-bound control is specified by {@link setControlToPaginate ControlToPaginate}, which must be the ID path of the target control reaching from the pager's naming container. Note, the target control must have its {@link TDataBoundControl::setAllowPaging AllowPaging} set to true. TPager can display three different UIs, specified via {@link setMode Mode}: - NextPrev: a next page and a previous page button are rendered. - Numeric: a list of page index buttons are rendered. - List: a dropdown list of page indices are rendered. When the pager mode is either NextPrev or Numeric, the paging buttons may be displayed in three types by setting {@link setButtonType ButtonType}: - LinkButton: a hyperlink button - PushButton: a normal button - ImageButton: an image button (please set XXXPageImageUrl properties accordingly to specify the button images.) Since Prado 3.2.1, you can use the {@link setButtonCssClass ButtonCssClass} property to specify a css class that will be applied to each button created by the pager in NextPrev or Numeric mode. TPager raises an {@link onPageIndexChanged OnPageIndexChanged} event when the end-user interacts with it and specifies a new page (e.g. clicking on a page button that leads to a new page.) The new page index may be obtained from the event parameter's property {@link TPagerPageChangedEventParameter::getNewPageIndex NewPageIndex}. Normally, in the event handler, one can set the {@link TDataBoundControl::getCurrentPageIndex CurrentPageIndex} to this new page index so that the new page of data is rendered. Multiple pagers can be associated with the same data-bound control.
Since: 3.0.2
Author: Qiang Xue ([email protected])
Inheritance: extends TWebControl, implements Prado\Web\UI\INamingContainer
Datei anzeigen Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
bubbleEvent ( $sender, $param ) : boolean Processes a bubbled event.
getButtonCssClass ( ) : string
getButtonType ( ) : TPagerButtonType
getControlToPaginate ( ) : string
getCurrentPageIndex ( ) : integer
getFirstPageImageUrl ( ) : string
getFirstPageText ( ) : string
getIsFirstPage ( ) : boolean
getIsLastPage ( ) : boolean
getLastPageImageUrl ( ) : string
getLastPageText ( ) : string
getMode ( ) : TPagerMode
getNextPageImageUrl ( ) : string
getNextPageText ( ) : string
getNumericPageImageUrl ( ) : string
getPageButtonCount ( ) : integer
getPageCount ( ) : integer
getPrevPageImageUrl ( ) : string
getPrevPageText ( ) : string
listIndexChanged ( $sender, $param ) Event handler to the OnSelectedIndexChanged event of the dropdown list.
loadState ( ) Restores the pager state.
onPageIndexChanged ( $param ) This event is raised when page index is changed due to a page button click.
onPreRender ( $param ) Performs databinding to populate data items from data source.
render ( $writer ) Renders the control.
setButtonCssClass ( $value )
setButtonType ( $value )
setControlToPaginate ( $value ) Sets the ID path of the control whose content would be paginated.
setFirstPageImageUrl ( $value )
setFirstPageText ( $value )
setLastPageImageUrl ( $value )
setLastPageText ( $value )
setMode ( $value )
setNextPageImageUrl ( $value )
setNextPageText ( $value )
setNumericPageImageUrl ( $value ) Sets the image URL for the numeric page buttons.
setPageButtonCount ( $value )
setPrevPageImageUrl ( $value )
setPrevPageText ( $value )

Protected Methods

Method Description
buildListPager ( ) Builds a dropdown list pager
buildNextPrevPager ( ) Builds a next-prev pager
buildNumericPager ( ) Builds a numeric pager
buildPager ( ) Builds the pager content based on the pager mode.
createPagerButton ( $buttonType, $enabled, $text, $commandName, $commandParameter ) : mixed Creates a pager button.
getPageImageUrl ( $text, $commandName )
setCurrentPageIndex ( $value )
setPageCount ( $value )

Method Details

bubbleEvent() public method

This method overrides parent's implementation by wrapping event parameter for OnCommand event with item information.
public bubbleEvent ( $sender, $param ) : boolean
return boolean whether the event bubbling should stop here.

buildListPager() protected method

Builds a dropdown list pager
protected buildListPager ( )

buildNextPrevPager() protected method

Builds a next-prev pager
protected buildNextPrevPager ( )

buildNumericPager() protected method

Builds a numeric pager
protected buildNumericPager ( )

buildPager() protected method

Current implementation includes building 'NextPrev', 'Numeric' and 'DropDownList' pagers. Derived classes may override this method to provide additional pagers.
protected buildPager ( )

createPagerButton() protected method

Depending on the button type, a TLinkButton or a TButton may be created. If it is enabled (clickable), its command name and parameter will also be set. Derived classes may override this method to create additional types of buttons, such as TImageButton.
protected createPagerButton ( $buttonType, $enabled, $text, $commandName, $commandParameter ) : mixed
return mixed the button instance

getButtonCssClass() public method

Since: 3.2.1
public getButtonCssClass ( ) : string
return string the css class of the buttons.

getButtonType() public method

public getButtonType ( ) : TPagerButtonType
return TPagerButtonType the type of command button for paging. Defaults to TPagerButtonType::LinkButton.

getControlToPaginate() public method

public getControlToPaginate ( ) : string
return string the ID path of the control whose content would be paginated.

getCurrentPageIndex() public method

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

getFirstPageImageUrl() public method

Since: 3.1.1
public getFirstPageImageUrl ( ) : string
return string the image URL for the first page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.

getFirstPageText() public method

public getFirstPageText ( ) : string
return string text for the first page button. Defaults to '<<'.

getIsFirstPage() public method

public getIsFirstPage ( ) : boolean
return boolean whether the current page is the first page Defaults to false.

getIsLastPage() public method

public getIsLastPage ( ) : boolean
return boolean whether the current page is the last page

getLastPageImageUrl() public method

Since: 3.1.1
public getLastPageImageUrl ( ) : string
return string the image URL for the last page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.

getLastPageText() public method

public getLastPageText ( ) : string
return string text for the last page button. Defaults to '>>'.

getMode() public method

public getMode ( ) : TPagerMode
return TPagerMode pager mode. Defaults to TPagerMode::NextPrev.

getNextPageImageUrl() public method

Since: 3.1.1
public getNextPageImageUrl ( ) : string
return string the image URL for the next page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.

getNextPageText() public method

public getNextPageText ( ) : string
return string text for the next page button. Defaults to '>'.

getNumericPageImageUrl() public method

See also: setNumericPageImageUrl
Since: 3.1.1
public getNumericPageImageUrl ( ) : string
return string the image URL for the numeric page buttons. This is only used when {@link getButtonType ButtonType} is 'ImageButton' and {@link getMode Mode} is 'Numeric'.

getPageButtonCount() public method

public getPageButtonCount ( ) : integer
return integer maximum number of pager buttons to be displayed. Defaults to 10.

getPageCount() public method

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

getPageImageUrl() protected method

Since: 3.1.1
protected getPageImageUrl ( $text, $commandName )

getPrevPageImageUrl() public method

Since: 3.1.1
public getPrevPageImageUrl ( ) : string
return string the image URL for the previous page button. This is only used when {@link getButtonType ButtonType} is 'ImageButton'.

getPrevPageText() public method

public getPrevPageText ( ) : string
return string text for the previous page button. Defaults to '<'.

listIndexChanged() public method

This handler will raise {@link onPageIndexChanged OnPageIndexChanged} event.
public listIndexChanged ( $sender, $param )

loadState() public method

This method overrides the parent implementation and is invoked when the control is loading persistent state.
public loadState ( )

onPageIndexChanged() public method

This event is raised when page index is changed due to a page button click.
public onPageIndexChanged ( $param )

onPreRender() public method

This method is invoked by {@link dataBind()}. You may override this function to provide your own way of data population.
public onPreRender ( $param )

render() public method

The method overrides the parent implementation by rendering the pager only when there are two or more pages.
public render ( $writer )

setButtonCssClass() public method

Since: 3.2.1
public setButtonCssClass ( $value )

setButtonType() public method

public setButtonType ( $value )

setControlToPaginate() public method

The ID path is the dot-connected IDs of the controls reaching from the pager's naming container to the target control.
public setControlToPaginate ( $value )

setCurrentPageIndex() protected method

protected setCurrentPageIndex ( $value )

setFirstPageImageUrl() public method

Since: 3.1.1
public setFirstPageImageUrl ( $value )

setFirstPageText() public method

public setFirstPageText ( $value )

setLastPageImageUrl() public method

Since: 3.1.1
public setLastPageImageUrl ( $value )

setLastPageText() public method

public setLastPageText ( $value )

setMode() public method

public setMode ( $value )

setNextPageImageUrl() public method

Since: 3.1.1
public setNextPageImageUrl ( $value )

setNextPageText() public method

public setNextPageText ( $value )

setNumericPageImageUrl() public method

This is actually a template for generating a set of URLs corresponding to numeric button 1, 2, 3, .., etc. Use {0} as the placeholder for the numbers. For example, the image URL http://example.com/images/button{0}.gif will be replaced as http://example.com/images/button1.gif, http://example.com/images/button2.gif, etc.
Since: 3.1.1
public setNumericPageImageUrl ( $value )

setPageButtonCount() public method

public setPageButtonCount ( $value )

setPageCount() protected method

protected setPageCount ( $value )

setPrevPageImageUrl() public method

Since: 3.1.1
public setPrevPageImageUrl ( $value )

setPrevPageText() public method

public setPrevPageText ( $value )