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

TreeView Data loading after dispatch is called

Thread ID:

Created:

Updated:

Platform:

Replies:

143196 Mar 8,2019 01:06 PM UTC Mar 12,2019 12:52 PM UTC React - EJ 2 3
loading
Tags: Treeview
Sonam Diwate
Asked On March 8, 2019 01:06 PM UTC

Hi,
I am trying to load data after api call.
I have created reducer and using connect as HOC. Once I will get data in my props I will use this data to load on treeview.
Please suggest some options to implement this functinality
Thanks,
Sonam Diwate

Christopher Issac Sunder K [Syncfusion]
Replied On March 11, 2019 12:01 PM UTC

Hi Sonam, 

Thank you for contacting Syncfusion support. 

We have prepared a sample based on your requirement. Here we bind the dataSource to the treeview after the dispatch is called on button click. Please find the code snippet. 

loadTree: function () { 
    store.dispatch(Click()); 
    var tree = document.getElementById("tree").ej2_instances[0]; 
    tree.fields.dataSource = store.getState(); 
    tree.dataBind(); 
} 

Please find the sample from the following link. 

You can use the following comments to make the sample runnable. 
  1. npm install
  2. npm install react-scripts --save
  3. npm start

Please check the sample and let us know whether it fulfills your requirement. 

Thanks, 
Christo

Sonam Diwate
Replied On March 12, 2019 12:47 PM UTC

Thanks for quick reply.


But here I want to bind nodeTemplate also. as we need to use custom templates.
Also I want to restrict some of child nodes to drag and drop as well as select node

Thanks,
Sonam Diwate

Christopher Issac Sunder K [Syncfusion]
Replied On March 12, 2019 12:52 PM UTC

Hi Sonam, 

We have prepared sample for binding datasource along with nodeTemplate. Please find the code snippet 

loadTree: function () { 
    store.dispatch(Click()); 
    var tree = document.getElementById("tree").ej2_instances[0]; 
    tree.fields.dataSource = store.getState(); 
    tree.cssClass = "custom"; 
    tree.nodeTemplate = '<div><img class="eimage" src="https://ej2.syncfusion.com/demos/src/images/employees/${eimg}.png\" alt="employee"/><div class="ename"> ${name} </div><div class="ejob"> ${job} </div></div>'; 
    tree.dataBind(); 
} 

Please check the sample from the following link and get back to us if you need any further assistance. 

Thanks, 
Christo

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