/
virtual-scroll.ts
47 lines (41 loc) · 1.07 KB
/
virtual-scroll.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Component, OnInit } from '@angular/core';
import { NzTreeNodeOptions } from 'ng-zorro-antd/tree';
@Component({
selector: 'nz-demo-tree-select-virtual-scroll',
template: `
<nz-tree-select
style="width: 250px"
[nzNodes]="nodes"
nzShowSearch
nzPlaceHolder="Please select"
nzVirtualHeight="300px"
nzHideUnMatched="true"
></nz-tree-select>
`
})
export class NzDemoTreeSelectVirtualScrollComponent implements OnInit {
nodes: NzTreeNodeOptions[] = [];
ngOnInit(): void {
const dig = (path = '0', level = 3): NzTreeNodeOptions[] => {
const list = [];
for (let i = 0; i < 10; i += 1) {
const key = `${path}-${i}`;
const treeNode: NzTreeNodeOptions = {
title: key,
key,
expanded: true,
children: [],
isLeaf: false
};
if (level > 0) {
treeNode.children = dig(key, level - 1);
} else {
treeNode.isLeaf = true;
}
list.push(treeNode);
}
return list;
};
this.nodes = dig();
}
}