PrimeNg tree-table how to distinguish between two different tables in a page.?

1.2k views Asked by At

When I expand a node on one table it is expanding other table automatically. How can I prevent that. Also, I have two different data for tow tables. But it is appending to both dataset.

2

There are 2 answers

1
Hrishikesh Kale On

I assume you will be assigning the 2 different variables to [value]="files1" of your tree data table value attribute.

this value attribute value defines the values to be shown in the data table. for an example, if you have 2 data sets and wants to populate it on 2 tree table you need to assign 2 variable like

files1: TreeNode[];
files2: TreeNode[];

this TreeNode should be imported from import {TreeNode} from 'primeng/api';

in your function from which you are getting values to show assign your values to above-mentioned files variable like

this.files1 = files1;
this.files2 = files2;

and in your view pass this files1 in tree table value attribute

<p-treeTable [value]="files1">

similarly, for second tree table pass this value like

<p-treeTable [value]="files2">
0
Md Rahaman On

Yes. I have done that. And I also have two different onChange method for both table an updated my my data based on the event. But it seems like both of the table expanding upon clicking one icon.