-
New Feature
-
Resolution: Done
-
Normal
-
8.6.0.1
-
None
-
Security Level: Jimmy
-
None
-
ZK 8.6.3 S1
-
None
Steps to Reproduce
1. run the attached code
Current Result
Object childNode = _model.getChild(node, i); in Tree.renderChildren() is always called during rendering. So the number of node a Tree get will actually larger than initRodSize (50). If getChild() costs heavily, e.g. getChild() retrieves data from a database, then initRodSize doesn't save the cost.
Proposed Solution
- getChild() later
- compute path based on the parent and current child index
private void renderChildren(Renderer renderer, Treechildren parent, Object node) throws Throwable { final int initSize = initRodSize(); for (int i = 0, j = _model.getChildCount(node); i < j; i++) { Treeitem ti = newUnloadedItem(); ti.setParent(parent); // Bug ZK-1696: must render all opened node to have correct page count TreeOpenableModel model = (TreeOpenableModel) _model; // render nodes when no ROD or within ROD range or opened node if (initSize < 0 || i < initSize || model.isPathOpened(toChildPath(node, i))) { Object childNode = _model.getChild(node, i); renderChildren0(renderer, parent, ti, childNode, i); } else { //render empty row ti.appendChild(new Treerow()); ti.getTreerow().appendChild(new Treecell()); } } } private int[] toChildPath(Object parentNode, int childIndex) { int[] parentPath = _model.getPath(parentNode); int[] path = Arrays.copyOf(parentPath, 3); path[parentPath.length] = childIndex; return path; }