CPagination
包 | system.web |
---|---|
继承 | class CPagination » CComponent |
可用自 | 1.0 |
版本 | $Id$ |
When data needs to be rendered in multiple pages, we can use CPagination to represent information such as total item count, page size, current page, etc. These information can be passed to pagers to render pagination buttons or links.
公共属性
属性 | 类型 | 描述 | 被定义在 |
---|---|---|---|
currentPage | integer | the zero-based index of the current page. | CPagination |
itemCount | integer | total number of items. | CPagination |
pageCount | integer | number of pages | CPagination |
pageSize | integer | number of items in each page. | CPagination |
pageVar | string | name of the GET variable storing the current page index. | CPagination |
params | array | the additional GET parameters (name=>value) that should be used when generating pagination URLs. | CPagination |
route | string | the route (controller ID and action ID) for displaying the paged contents. | CPagination |
公共方法
方法 | 描述 | 被定义在 |
---|---|---|
__call() | Calls the named method which is not a class method. | CComponent |
__construct() | Constructor. | CPagination |
__get() | Returns a property value, an event handler list or a behavior based on its name. | CComponent |
__isset() | Checks if a property value is null. | CComponent |
__set() | Sets value of a component property. | CComponent |
__unset() | Sets a component property to be null. | CComponent |
applyLimit() | Applies LIMIT and OFFSET to the specified query criteria. | CPagination |
asa() | Returns the named behavior object. | CComponent |
attachBehavior() | Attaches a behavior to this component. | CComponent |
attachBehaviors() | Attaches a list of behaviors to the component. | CComponent |
attachEventHandler() | Attaches an event handler to an event. | CComponent |
canGetProperty() | Determines whether a property can be read. | CComponent |
canSetProperty() | Determines whether a property can be set. | CComponent |
createPageUrl() | Creates the URL suitable for pagination. | CPagination |
detachBehavior() | Detaches a behavior from the component. | CComponent |
detachBehaviors() | Detaches all behaviors from the component. | CComponent |
detachEventHandler() | Detaches an existing event handler. | CComponent |
disableBehavior() | Disables an attached behavior. | CComponent |
disableBehaviors() | Disables all behaviors attached to this component. | CComponent |
enableBehavior() | Enables an attached behavior. | CComponent |
enableBehaviors() | Enables all behaviors attached to this component. | CComponent |
getCurrentPage() | CPagination | |
getEventHandlers() | Returns the list of attached event handlers for an event. | CComponent |
getItemCount() | CPagination | |
getPageCount() | CPagination | |
getPageSize() | CPagination | |
hasEvent() | Determines whether an event is defined. | CComponent |
hasEventHandler() | Checks whether the named event has attached handlers. | CComponent |
hasProperty() | Determines whether a property is defined. | CComponent |
raiseEvent() | Raises an event. | CComponent |
setCurrentPage() | CPagination | |
setItemCount() | CPagination | |
setPageSize() | CPagination |
属性详情
the zero-based index of the current page. Defaults to 0.
total number of items. Defaults to 0.
number of pages
number of items in each page. Defaults to 10.
name of the GET variable storing the current page index. Defaults to 'page'.
the additional GET parameters (name=>value) that should be used when generating pagination URLs. Defaults to null, meaning using the currently available GET parameters.
the route (controller ID and action ID) for displaying the paged contents. Defaults to empty string, meaning using the current route.
方法详情
public void __construct(integer $itemCount=0)
| ||
$itemCount | integer | total number of items. |
Constructor.
public void applyLimit(CDbCriteria $criteria)
| ||
$criteria | CDbCriteria | the query criteria that should be applied with the limit |
Applies LIMIT and OFFSET to the specified query criteria.
public string createPageUrl(CController $controller, integer $page)
| ||
$controller | CController | the controller that will create the actual URL |
$page | integer | the page that the URL should point to. This is a zero-based index. |
{return} | string | the created URL |
Creates the URL suitable for pagination. This method is mainly called by pagers when creating URLs used to perform pagination. The default implementation is to call the controller's createUrl method with the page information. You may override this method if your URL scheme is not the same as the one supported by the controller's createUrl method.
public integer getCurrentPage(boolean $recalculate=true)
| ||
$recalculate | boolean | whether to recalculate the current page based on the page size and item count. |
{return} | integer | the zero-based index of the current page. Defaults to 0. |
public integer getItemCount()
| ||
{return} | integer | total number of items. Defaults to 0. |
public integer getPageCount()
| ||
{return} | integer | number of pages |
public integer getPageSize()
| ||
{return} | integer | number of items in each page. Defaults to 10. |
public void setCurrentPage(integer $value)
| ||
$value | integer | the zero-based index of the current page. |
public void setItemCount(integer $value)
| ||
$value | integer | total number of items. |
public void setPageSize(integer $value)
| ||
$value | integer | number of items in each page |