File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,26 @@ export class NzTreeBaseService {
55
55
return this . conductNodeState ( 'select' ) ;
56
56
}
57
57
58
+ /**
59
+ * get checked node keys
60
+ */
61
+ getCheckedNodeKeys ( ) : NzTreeNodeKey [ ] {
62
+ const keys : NzTreeNodeKey [ ] = [ ] ;
63
+ const checkedNodes = this . getCheckedNodeList ( ) ;
64
+
65
+ const calc = ( nodes : NzTreeNode [ ] ) : void => {
66
+ nodes . forEach ( node => {
67
+ keys . push ( node . key ) ;
68
+ if ( node . children . length < 1 ) return ;
69
+ calc ( node . children ) ;
70
+ } ) ;
71
+ } ;
72
+
73
+ calc ( checkedNodes ) ;
74
+
75
+ return keys ;
76
+ }
77
+
58
78
/**
59
79
* return checked nodes
60
80
*/
Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ export class NzTreeComponent
224
224
225
225
@Output ( ) readonly nzExpandedKeysChange : EventEmitter < string [ ] > = new EventEmitter < string [ ] > ( ) ;
226
226
@Output ( ) readonly nzSelectedKeysChange : EventEmitter < string [ ] > = new EventEmitter < string [ ] > ( ) ;
227
- @Output ( ) readonly nzCheckedKeysChange : EventEmitter < string [ ] > = new EventEmitter < string [ ] > ( ) ;
227
+ @Output ( ) readonly nzCheckedKeysChange : EventEmitter < NzTreeNodeKey [ ] > = new EventEmitter < NzTreeNodeKey [ ] > ( ) ;
228
228
@Output ( ) readonly nzSearchValueChange = new EventEmitter < NzFormatEmitEvent > ( ) ;
229
229
@Output ( ) readonly nzClick = new EventEmitter < NzFormatEmitEvent > ( ) ;
230
230
@Output ( ) readonly nzDblClick = new EventEmitter < NzFormatEmitEvent > ( ) ;
@@ -426,6 +426,8 @@ export class NzTreeComponent
426
426
// Cause check method will rerender list, so we need recover it and next the new event to user
427
427
const eventNext = this . nzTreeService . formatEvent ( 'check' , node , event . event ! ) ;
428
428
this . nzCheckBoxChange . emit ( eventNext ) ;
429
+ const checkedKeys = this . nzTreeService . getCheckedNodeKeys ( ) ;
430
+ this . nzCheckedKeysChange . emit ( checkedKeys ) ;
429
431
break ;
430
432
case 'dragstart' :
431
433
// if node is expanded
You can’t perform that action at this time.
0 commit comments