We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding nodes

Thread ID:

Created:

Updated:

Platform:

Replies:

150150 Dec 23,2019 08:41 AM UTC Dec 31,2019 09:02 AM UTC JavaScript - EJ 2 3
loading
Tags: TreeView
Neil
Asked On December 23, 2019 08:41 AM UTC

Hi
  I am using Javascript/HTML/CSS and wish to start the web site with a blank Treeview, then when receiving data from our server wish to add the nodes. I dont want to bind the data automatically, I plan to receive JSON data (some of the data not for the TreeView) add it into a buffer then display the tree. Is there an example of creating and displaying an empty treeview, then for example by pressing a button the data is added?

Many Thanks
Neil


Sowmiya Padmanaban [Syncfusion]
Replied On December 24, 2019 10:59 AM UTC

Hi Neil, 
 
Greetings from Syncfusion support. 
 
We have checked your reported query that dynamically add the data to the TreeView component. To achieve your requirement, initially set the dataSource property as empty for TreeView component and add the dataSource during button click. Refer the below code snippet for dynamically add dataSource. 
 
document.getElementById('add').onclick = () => {  
   treeObj.fields.dataSource = (dataSource as any).defaultData; 
  } 
 
 
We have prepared a sample for your reference. In that sample, we load the dataSource dynamically. Refer the sample link below. 
 
To know more about the TreeView component, refer the below links. 
 
 
 
 
Please let us know, if you have any concerns. 
 
 
Regards, 
Sowmiya.P 


Pon Geetha A J [Syncfusion]
Replied On December 26, 2019 04:40 AM UTC

 Hi 
  Can this be done in Javascript/html instead of a ts file? 
 
Regards 
Neil 
 ________________________________________________ 
  
Hi 
Many thanks for below. It works great, but what is the .ts file extension? I tried to place it in my javascript file but it mentions it can only be placed in a ts file 
 
Best Regards 
Neil 


Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On December 31, 2019 09:02 AM UTC

Hi Neil, 
  
Yes, you can use EJ2 TreeView in JavaScript. For your convenience, we have modified the previously provided sample for JavaScript platform. 
  
Please, find the sample from the following link. 
  
  
Also, to know more about rendering EJ2 TreeView component in JavaScript. Please, check out the following links. 
  
  
  
To know about Syncfusion components, please check the following link. 
  
  
Please, let us know if you need any further assistance. 
  
Regards, 
Shameer Ali Baig S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon