Explorar el Código

feat(tree): 增加虚拟行号获取方法

zhangweicheng hace 5 años
padre
commit
0be1c765af
Se han modificado 1 ficheros con 12 adiciones y 0 borrados
  1. 12 0
      tree/src/nodeCtx.ts

+ 12 - 0
tree/src/nodeCtx.ts

@@ -27,6 +27,18 @@ export class NodeContext {
     return this.tree.data.indexOf(this.ref);
     return this.tree.data.indexOf(this.ref);
   }
   }
 
 
+  // 获取树结构展开显示的行号
+  visualRow(): number {
+    let row = 0;
+    for (const n of this.tree.data) {
+      if (this.ref === n) return row;
+      if (n.getCtx().visible()) {
+        row += 1;
+      }
+    }
+    return row;
+  }
+
   // 节点在相同父节点下的行号
   // 节点在相同父节点下的行号
   rowInParent(): number {
   rowInParent(): number {
     return this.brothers().indexOf(this.ref);
     return this.brothers().indexOf(this.ref);