Kooboo content paging

Paging is a very common task when querying lists of content. Kooboo Data Rule and CmsPager method provide an easy way to do paging.

Html.Pager
This method will produce a standard paging html code out with link to each page numbers. Below is a sample HTML produced by this method.
 
 
The actually look & feel of this pager should be controlled by CSS.

This Method has four overloads, one example as below.
 
 


pageSize: the number of records per page.
currentPage: Current page number, starting from 1.
totalItemCount: Total record count.
pageIndexName: The string of PageIndex, default is "PageIndex"
routeValues: additional parameters when generating the URL.

Every content template has defined parameters for paging. Source code as below.
 
 

You can use Pager method by simply adding below code to your content template.
 
 

You can use paging variables in thte Data Rule definition for paging query, see below screen.

PageSize can be a number or a parameter. When it is a number, you have to make sure that it has the same value as the PageSize in content template. If you use {PageSize}, you can overwrite the value at content template and this value will be assigned to {PageSize} in the Data rule. PageSize has a default valuve of 20

PageIndex is the current page number. By the default, we use the "PageIndex" variable name. You may define your own or overwrite it within content template. This value is important for DataRule paging query.

TotalCount is the total records which can be returned without paging variables. It can be used to calculated total page numbers. In the default configuration, we will take a value from viewdata, so user only need to define a DataRule with a DataName of "TotalCount". See above screen as an example.