0

On click of the last element of tree table, I want to route it to another screen (url) and show a table.

For example:

I want to select the last node of the parent node of every element in the tree table.

On click of child node, it should navigate to a new screen.

Looks like this:

>Aamir
 >Ranchi
    > 12
    > 20
 > Bangalore
    > 22
>Abhinav
 > Bangalore
   >26

So when user select 12, 20 ,22 or 26, it should naviagte to a new screen.

Template :

<h3>Dynamic Columns</h3>
<p-treeTable [value]="files2" [columns]="cols" >
    <ng-template pTemplate="header" let-columns>
        <tr [ttRow]="rowNode">
            <th *ngFor="let col of columns">
                {{col.header}}
            </th>
        </tr>
    </ng-template>
    <ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
        <tr >
            <td *ngFor="let col of columns; let i = index">
                <p-treeTableToggler [rowNode]="rowNode" *ngIf="i == 0"></p-treeTableToggler>
                {{rowData[col.field]}}
            </td>
        </tr>
    </ng-template>
</p-treeTable>
codehunter
  • 81
  • 2
  • 14

1 Answers1

1

I think that important thing here that you didn't mention is that this is primeng-treetable.

Playing a bit with this component and reading the source code I've caught that you can use rowNode template variable that has all necessary info about the node. In your case you can check if node has no children to use link:

<a href="/" *ngIf="!rowNode.node.children">{{rowData.name}}</a>
<span *ngIf="rowNode.node.children">{{rowData.name}}</span>

You can check working stackblitz here: https://stackblitz.com/edit/test-primeng-7cqjzl

Danil Gudz
  • 2,233
  • 16
  • 16
  • i want to show table which consist of list of details about the children. and data vareis from children to children – codehunter Jan 15 '19 at 13:10