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

Close treenode did not render tree correctly in paging mold

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 7.0.3
    • 7.0.2
    • Components
    • Security Level: Jimmy

      Reproducible sample:

      <zk>
          <label multiline="true">
          1. Open tree node 1, 3, 7, 15, 31, 63, 127, 255
          2. Navigate to page 2 then navigate back to page 1
          3. Close tree node 255
          4. Should see tree node 4, 8 (bug if not seeing).
          </label>
          <window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('demo.TreeVM')">
              <paging id="paging" pageSize="15" totalSize="@load(vm.totalsize)" />
              <tree id="tree" model="@load(vm.model)" mold="paging" pageSize="15" rows="15">
                  <treecols>
                      <treecol label="Col" />
                  </treecols>
                  <template name="model" var="each">
                      <treeitem value="@load(each)">
                          <treerow>
                              <treecell label="${each}" />
                          </treerow>
                      </treeitem>
                  </template>
              </tree>
          </window>
      </zk>
      
      public class TreeVM {
          private BinaryTreeModel<String> model;
          @Init
          public void init() {
              List<String> list = new ArrayList<String>();
              for (int i = 0; i < 1000; i++) {
                  list.add("" + i);
              }
              model = new BinaryTreeModel<String>(list);
          }
          public BinaryTreeModel<String> getModel() {
              return model;
          }
      
          public void setModel(BinaryTreeModel<String> model) {
              this.model = model;
          }
      }
      
      public class BinaryTreeModel<T> extends AbstractTreeModel<T> {
      
          private static final long serialVersionUID = 5067310002210333471L;
          private List<T> _tree = null;
      
          public BinaryTreeModel(List<T> tree) {
              super(tree.get(0));
              _tree = tree;
          }
      
          public boolean isLeaf(Object node) {
              return (getChildCount(node) == 0);
          }
      
          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 int getIndexOfChild(Object arg0, Object arg1) {
              return 0;
          }
      }
      

            hanhsu hanhsu
            vincentjian vincentjian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: