EasyUI Forum
May 03, 2024, 10:49:35 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Tree data to string  (Read 3702 times)
sky-t
Full Member
***
Posts: 145


View Profile
« on: March 24, 2020, 06:24:21 AM »

Hi there,

is there a chance to convert whole tree data incl. children to a string (JSON) to send it to a server?



Thank yout
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: March 26, 2020, 08:31:36 PM »

Please use JSON.stringify to convert the JSON object to a string.
Code:
var s = JSON.stringify(...);
console.log(s);
Logged
sky-t
Full Member
***
Posts: 145


View Profile
« Reply #2 on: March 28, 2020, 01:21:31 AM »

Hi jarry,

thank you for your reply.

I use this code:
Code:
        var data=$('#tree_main_west').tree('getData', roots[i].target);
        var s = JSON.stringify(data);

And get the error:

Uncaught TypeError: Converting circular structure to JSON


How can i solve this problem?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: March 29, 2020, 01:57:25 AM »

This code get all the tree data and stringnify it.
Code:
var data = $('#tt').tree('getData',$('#tt').tree('getRoot').target)
var s = JSON.stringify(data);
console.log(s)
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!