leovo2708 / ngx-treeview

An Angular treeview component with checkbox
MIT License
363 stars 337 forks source link

Template to expand / collapse on name click #321

Open tulipandmills opened 2 years ago

tulipandmills commented 2 years ago

How can I make the items to be clickable, just like the icon, to toggle the expansion state? I am not using selection features

Please find my current example working with only the icon being clickable, not the icons:

<tree-ngx [nodeItems]="tree" [options]="options" #treeRef>
                <ng-template #nodeNameTemplate let-node="node" let-context="context">
                    <ng-container *ngIf="node.code; else Else">
                        <span>code: </span>
                        <a (click)="openTab(node.code)" class="link">
                            <span>{{node.code}}</span>
                            <i class="pi pi-external-link popIcon"></i>
                        </a>
                    </ng-container>
                    <ng-template #Else>
                        <span>{{node.name}}</span>
                    </ng-template>
                </ng-template>
            </tree-ngx>