Page 1 of 1

TreeTable - Converting circular structure to JSON *solved*

Posted: 09 Jul 2019, 15:13
by koesper
I'm trying to get the TreeTable to work in my project, but when I expand the table, i get a Circular structure error in the console.

Code: Select all

ERROR
Error: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'children' -> object with constructor 'Array'
| index 0 -> object with constructor 'Object'
--- property 'parent' closes the circle
I've been able to recreate it in this stackblitz:
https://stackblitz.com/edit/github-uxyk8d
(based on the example in https://www.primefaces.org/primeng/#/treetable)


It might relate to this bugreport, but I dont see what the solution should be
https://github.com/primefaces/primeng/issues/2706

Re: TreeTable - Converting circular structure to JSON *solved*

Posted: 09 Jul 2019, 16:12
by koesper
Solved it...
This was an official heisenbug... it only existed when debugging....

I added a line in my html to see the structure the TreeTable was based on...

Code: Select all

<pre>{{files | json}}</pre>

Apparently, when you press the treetabletoggler, that structure is updated, with parent&child objects, creating a circular structure...
And the '| json' pipe cant handle that..

The problem wasnt in TreeTable, but in my code. Remove the debug line, and it works!

Re: TreeTable - Converting circular structure to JSON *solved*

Posted: 10 Jul 2019, 08:14
by yigitfindikli
koesper wrote:
09 Jul 2019, 16:12
Solved it...
This was an official heisenbug... it only existed when debugging....

I added a line in my html to see the structure the TreeTable was based on...

Code: Select all

<pre>{{files | json}}</pre>

Apparently, when you press the treetabletoggler, that structure is updated, with parent&child objects, creating a circular structure...
And the '| json' pipe cant handle that..

The problem wasnt in TreeTable, but in my code. Remove the debug line, and it works!
Glad to hear!

Best Regards.