TPager creates a pager that provides UI for end-users to interactively specify which page of data to be rendered in a TDataBoundControl-derived control, such as TDataList, TRepeater, TCheckBoxList, etc. The target data-bound control is specified by the ControlToPaginate property, which must be the ID path of the target control reaching from the pager's naming container.
Note, the target data-bound control must have its AllowPaging set to true. Otherwise the pager will be invisible. Also, in case when there is only one page of data available, the pager will also be invisible.
TPager can display one of the following three types of user interface, specified via its Mode property:
- NextPrev - a next page and a previous page button are rendered on each page.
- Numeric - a list of page index buttons are rendered.
- DropDownList - a dropdown list of page indices is rendered.
These user interfaces may be further customized by configuring the following properties
- NextPageText and PrevPageText - the label of the next/previous page button. These properties are used when the pager Mode is NextPrev or Numeric.
- FirstPageText and LastPageText - the label of the first/last page button. If empty, the corresponding button will not be displayed. These properties are used when the pager Mode is NextPrev or Numeric.
- PageButtonCount - the maximum number of page index buttons on a page. This property is used when the pager Mode is Numeric.
- ButtonType - type of page buttons, either PushButton meaning normal form submission buttons, or LinkButton meaning hyperlink buttons.
Since Prado 3.2.1, you can use the 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 OnPageIndexChanged event when an end-user interacts with it and specifies a new page (e.g. by clicking on a next page button that would lead to the next page.) Developers may write handlers to respond to this event and obtain the desired new page index from the event parameter's property NewPageIndex. Using this new page index, one can feed a new page of data to the associated data-bound control.