From Documentation
Revision as of 10:43, 19 January 2022 by Hawk (talk | contribs) (correct highlight (via JWB))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Stop.png This documentation is for an older version of ZK. For the latest one, please click here.

A paging component is used to separate long content into multiple pages. For example, assume that you have 100 items and prefer to show 20 items at a time, you can use the paging components as follows.

	<paging totalSize="100" pageSize="20"/>

When a user clicks the paging component, the onPaging event is sent along with an instance of PagingEvent to the paging component. To decide which portion of your 100 items are visible, you can add a listener to the paging component. Please note that the code below is pseudo code, you can find a real world example here.

	<paging id="paging" />
	List result = new SearchEngine().find("ZK");
	//assume SearchEngine.find() will return a list of items.
	paging.addEventListener("onPaging", new org.zkoss.zk.ui.event.EventListener() {
		public void onEvent(Event event) {
			int pgno = event.getPaginal().getActivePage();
			int ofs = pgno * event.getPaginal().getPageSize();
			new Viewer().redraw(result, ofs, ofs + event.getPaginal().
				getPageSize() - 1);
			//assume redraw(List result, int b, int e) will display
			//from the b-th item to the e-th item

Paging supports OS mold.

For those who prefer the legacy layout of ZK 3.0』s Button component, please use OS mold as follows:

	<paging mold="os" totalSize="100" pageSize="10"/>


Paging with List Boxes and Grids

The listbox and grid component supports paging intrinsically, therefore you don't need to specify a paging component explicitly as above, unless you want to have different visual layout or to control multiple list boxes and grids with one paging component.

Please refer to the Grids section for more details.

Paging with Tree

To use paging with trees, you have to set the mold="paging". Related attributes pageSize and pagingPosition are optional.

	<tree mold="paging" pageSize="4" pagingPosition="both">

Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.