Parcourir la source

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

zhangweicheng il y a 5 ans
Parent
commit
0be1c765af
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  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);
   }
 
+  // 获取树结构展开显示的行号
+  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 {
     return this.brothers().indexOf(this.ref);