|
Processing... 500+ live data distributed to 3 pages for an easier view !
Description & Source Code
The paging feature allows large data to be distributed in a page representation of tree items. A paging indicator tracks the current page relative to all pages, and it may be placed at top, bottom, or both top and bottom. Two different molds (look and feel) are available for the paging feature. paging.zul
<zk> <zscript><![CDATA[ TreeModel btm = new demo.tree.load_on_demand.BinaryTreeModel( new ArrayList( new demo.data.BigList(1000))); ]]></zscript> <tree id="tree" mold="paging" pageSize="15" rows="15" model="${btm}"> <attribute name="onCreate"><![CDATA[ tree.renderItemByPath(new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); tree.renderItemByPath(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); ]]></attribute> </tree> </zk> paging_ctrl.zul
<vlayout> <radiogroup onCheck="tree.pagingPosition = self.selectedItem.label;"> <vlayout> <label value="Paging Indicator Placement :" /> <radio label="top" /> <radio label="bottom" checked="true" /> <radio label="both" /> </vlayout> </radiogroup> <div height="10px" /> <checkbox label="Change Paging Mold"> <attribute name="onCheck"><![CDATA[ tree.pagingChild.mold = "os".equals(tree.pagingChild.mold) ? "default" : "os"; ]]></attribute> </checkbox> </vlayout> BigList.java
package demo.data; import java.util.AbstractList; public class BigList extends AbstractList<Integer> { private int size; public BigList(int sz) { if (sz < 0) throw new IllegalArgumentException("Negative not allowed: " + sz); size = sz; } public int size() { return size; } public Integer get(int j) { return Integer.valueOf(j); } } BinaryTreeModel.java
package demo.tree.load_on_demand; import java.util.ArrayList; import org.zkoss.zul.AbstractTreeModel; import org.zkoss.zul.ext.TreeSelectableModel; public class BinaryTreeModel<T> extends AbstractTreeModel<T> implements TreeSelectableModel { private static final long serialVersionUID = 7822729366554623684L; private ArrayList<T> _tree = null; /** * Constructor * * @param tree * the list is contained all data of nodes. */ public BinaryTreeModel(ArrayList<T> tree) { super(tree.get(0)); _tree = tree; } // TreeModel // public T getChild(Object parent, int index) { int i = _tree.indexOf(parent) * 2 + 1 + index; if (i >= _tree.size()) return null; else return _tree.get(i); } public int getChildCount(Object parent) { int count = 0; if (getChild(parent, 0) != null) count++; if (getChild(parent, 1) != null) count++; return count; } public boolean isLeaf(Object node) { return (getChildCount(node) == 0); } /** * @since 5.0.6 * @see org.zkoss.zul.TreeModel#getIndexOfChild(java.lang.Object, * java.lang.Object) */ @Override public int getIndexOfChild(Object arg0, Object arg1) { return 0; } }
Copyright © 2005-2024 Potix Corporation All rights reserved.
|
Processing... |