Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4203

improve renderChildren() by getChild() later and better way to calculate a path

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: 8.6.0.1
    • Fix Version/s: 8.6.3
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None
    • gh.sprint.customfield.default.name:
      ZK 8.6.3 S1

      Description

      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;
            }
        

        Attachments

          Activity

            People

            • Assignee:
              DevChu DevChu
              Reporter:
              hawk hawk
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: