-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:tree-select): support virtual scroll (#5760)
close #5589
- Loading branch information
Showing
7 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 6 | ||
title: | ||
zh-CN: 虚拟滚动 | ||
en-US: Virtual Scroll | ||
--- | ||
|
||
## zh-CN | ||
|
||
设定 `nzVirtualHeight` 开启虚拟滚动。 | ||
|
||
## en-US | ||
|
||
Set `nzVirtualHeight` to enable virtual scroll. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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" | ||
></nz-tree-select> | ||
` | ||
}) | ||
export class NzDemoTreeSelectVirtualScrollComponent implements OnInit { | ||
nodes: NzTreeNodeOptions[] = []; | ||
|
||
ngOnInit(): void { | ||
const dig = (path = '0', level = 3) => { | ||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters