forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(module: tree): provide some quick methods & support nzCheckSt…
…rictly (NG-ZORRO#1354) * [WIP] feature(module: tree): provide some quick methods & support nzCheckStrictly * fix ci test * fix(module: tree): support nzCheckStrictly * fix(module: tree): fix ci error * fix(module: tree): fix some codes * fix lint error
- Loading branch information
Showing
12 changed files
with
355 additions
and
137 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 7 | ||
title: | ||
zh-CN: 常用方法 | ||
en-US: common methods | ||
--- | ||
|
||
## zh-CN | ||
|
||
Tree组件通过几种常用方法供用户快速获取数据。 | ||
|
||
## en-US | ||
|
||
Tree components provide quick access to data through several common methods. |
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,77 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNode } from 'ng-zorro-antd'; | ||
|
||
@Component({ | ||
selector: 'nz-demo-tree-method', | ||
template: ` | ||
<nz-tree | ||
#nzTree | ||
[(ngModel)]="nodes" | ||
[nzCheckable]="true" | ||
[nzMultiple]="true" | ||
[nzCheckStrictly]="true" | ||
[nzDefaultExpandedKeys]="expandKeys" | ||
[nzDefaultCheckedKeys]="checkedKeys" | ||
[nzDefaultSelectedKeys]="selectedKeys" | ||
[nzDefaultExpandAll]="expandDefault" | ||
(nzClick)="mouseAction('click',$event)" | ||
(nzCheckBoxChange)="mouseAction('check',$event)" | ||
(nzDblClick)="mouseAction('dblclick', $event)" | ||
> | ||
</nz-tree>` | ||
}) | ||
|
||
export class NzDemoTreeMethodComponent implements OnInit { | ||
@ViewChild('nzTree') nzTree: NzTreeComponent; | ||
expandKeys = [ '1001', '10001' ]; | ||
checkedKeys = [ '10001' ]; | ||
selectedKeys = [ '10001', '100011' ]; | ||
expandDefault = false; | ||
nodes = [ | ||
new NzTreeNode({ | ||
title : 'root1', | ||
key : '1001', | ||
children: [ | ||
{ | ||
title : 'child1', | ||
key : '10001', | ||
children: [ | ||
{ | ||
title : 'child1.1', | ||
key : '100011', | ||
children: [] | ||
}, | ||
{ | ||
title : 'child1.2', | ||
key : '100012', | ||
children: [ | ||
{ | ||
title : 'grandchild1.2.1', | ||
key : '1000121', | ||
isLeaf : true, | ||
disabled: true | ||
}, | ||
{ | ||
title : 'grandchild1.2.2', | ||
key : '1000122', | ||
isLeaf: true | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}) | ||
]; | ||
|
||
mouseAction(name: string, event: NzFormatEmitEvent): void { | ||
console.log(name, event); | ||
// just for demo, should get in ngAfterViewInit | ||
console.log('checkedNodes: %o', this.nzTree.getCheckedNodeList()); | ||
console.log('selectedNodes: %o', this.nzTree.getSelectedNodeList()); | ||
console.log(this.nzTree.nzTreeService.getCheckedNodeList()); | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
} |
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
Oops, something went wrong.