diff --git a/src/datas/hierarchical-data.ts b/src/datas/hierarchical-data.ts index 1ba3017..02d0e0f 100644 --- a/src/datas/hierarchical-data.ts +++ b/src/datas/hierarchical-data.ts @@ -8,7 +8,23 @@ export const HierarchicalCountries = [ name: 'Angola', capital: 'Luanda', phone: '244', - currency: 'AOA' + currency: 'AOA', + children: [ + { + id: 'TT', + name: 'Test', + capital: 'Luanda', + phone: '244', + currency: 'AOA', + children: [ + { + id: 'TU', + name: 'Test2', + capital: 'Luanda', + phone: '244', + currency: 'AOA' + }] + }] }, { id: 'BF', diff --git a/src/ngx-tree-select/src/services/select.service.ts b/src/ngx-tree-select/src/services/select.service.ts index 1ff3b73..0fbf58d 100644 --- a/src/ngx-tree-select/src/services/select.service.ts +++ b/src/ngx-tree-select/src/services/select.service.ts @@ -117,6 +117,17 @@ export class SelectService { } } + public setAllOpoen(items: SelectableItem[]) { + for (const itm of items) { + if (itm.hasChild) { + itm.isOpen = true; + this.setAllOpoen(itm.children); + } else { + itm.isOpen = true; + } + } + } + public setConfiguration(delegate: OptionDelegate, processItems: boolean): void { const modelBck = this._options.model; delegate(this._options); @@ -144,6 +155,9 @@ export class SelectService { for (const item of this._items) { if (this._options.expandMode === ExpandMode.All) { item.isOpen = true; + if(item.hasChild){ + this.setAllOpoen(item.children); + } } else if (this._options.expandMode === ExpandMode.Selection && item.children) { item.isOpen = item.children.some((itm: SelectableItem) => itm.isOpen || itm.selected); } else {