I'm trying to find a way how to make nz-tree-select be opened by default on dropdown menu item click.
I'm trying to use (nzVisibleChange) event from nz-dropdown alongside [(nzOpen)] state from nz-tree-select. But no luck for now. Also I have an access to NzTreeSelectComponent, but I'm not sure how can I use it.
<button nz-button nz-dropdown [nzDropdownMenu]="menu"
(nzVisibleChange)="dropDownVisibleChange($event)"
nzPlacement="bottomLeft"
nzTrigger="click">Button
</button>
<nz-dropdown-menu #menu="nzDropdownMenu">
<nz-tree-select #tree [(nzOpen)]="isOpen" class="tree-select" nzNoAnimation nzShowExpand [nzMaxTagCount]="2"
[nzNodes]="nodes" [nzHideUnMatched]="true" nzVirtualHeight="498px" [nzShowSearch]="true" nzCheckable
nzPlaceHolder="Please select">
</nz-tree-select>
</nz-dropdown-menu>
@Component({
selector: "my-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent implements AfterViewInit, AfterContentInit {
isOpen: boolean;
@ViewChild(NzTreeSelectComponent, { static: true })
tree: NzTreeSelectComponent;
nodes = [
{
title: "parent 1",
key: "100",
children: [
{
title: "parent 1-0",
key: "1001",
children: [
{ title: "leaf 1-0-0", key: "10010", isLeaf: true },
{ title: "leaf 1-0-1", key: "10011", isLeaf: true }
]
},
{
title: "parent 1-1",
key: "1002",
children: [{ title: "leaf 1-1-0", key: "10020", isLeaf: true }]
}
]
}
];
dropDownVisibleChange(open: boolean): void {
console.log("VisibleChange", open);
this.isOpen = open;
}
ngAfterViewInit(): void {
console.log(this.tree);
}
ngAfterContentInit(): void {
console.log(this.tree);
}
}