Skip to content

Commit

Permalink
fix(module: tree): sync checked node status and push to checkedNodeLi…
Browse files Browse the repository at this point in the history
…st (#1809)

close #1802
  • Loading branch information
Jason authored and vthinkxie committed Jul 22, 2018
1 parent 88b0915 commit 92ed5ee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/tree/nz-tree-node.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
[nzDefaultExpandAll]="nzDefaultExpandAll"
[nzDefaultExpandedKeys]="nzDefaultExpandedKeys"
[nzDefaultSelectedKeys]="nzDefaultSelectedKeys"
[nzDefaultCheckedKeys]="nzDefaultCheckedKeys"
[nzTreeTemplate]="nzTreeTemplate"
(clickNode)="clickNode.emit($event)"
(dblClick)="dblClick.emit($event)"
Expand Down
17 changes: 17 additions & 0 deletions components/tree/nz-tree-node.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ export class NzTreeNodeComponent implements OnInit, AfterViewInit {
return this._expandAll;
}

@Input()
set nzDefaultCheckedKeys(value: string[]) {
// should set checked node list
this._defaultCheckedKeys = value;
if (value && value.indexOf(this.nzTreeNode.key) > -1) {
if (this.nzCheckStrictly) {
this.nzTreeService.setCheckedNodeListStrict(this.nzTreeNode);
} else {
this.nzTreeService.setCheckedNodeList(this.nzTreeNode);
}
}
}

get nzDefaultCheckedKeys(): string[] {
return this._defaultCheckedKeys;
}

@Input()
set nzDefaultExpandedKeys(value: string[]) {
this._defaultExpandedKeys = value;
Expand Down
1 change: 1 addition & 0 deletions components/tree/nz-tree.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
[nzDefaultExpandAll]="nzDefaultExpandAll"
[nzDefaultExpandedKeys]="nzDefaultExpandedKeys"
[nzDefaultSelectedKeys]="nzDefaultSelectedKeys"
[nzDefaultCheckedKeys]="nzDefaultCheckedKeys"
(clickCheckBox)="nzCheckBoxChange.emit($event)"
(clickExpand)="nzExpandChange.emit($event)"
(clickNode)="nzClick.emit($event)"
Expand Down
2 changes: 2 additions & 0 deletions components/tree/nz-tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ describe('tree component test', () => {
[(ngModel)]="nodes"
[nzCheckable]="true"
[nzCheckStrictly]="true"
[nzDefaultCheckedKeys]="checkedKeys"
[nzMultiple]="multiple"
[nzShowLine]="showLine"
[nzShowExpand]="showExpand"
Expand All @@ -505,6 +506,7 @@ describe('tree component test', () => {
})

class NzDemoStrictTreeComponent {
checkedKeys = [ '100011' ];
nodes = [
new NzTreeNode({
title : 'root1',
Expand Down

0 comments on commit 92ed5ee

Please sign in to comment.