- Home
- Forum
- React - EJ 2
- TreeView Data loading after dispatch is called
TreeView Data loading after dispatch is called
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
SIGN IN To post a reply.
3 Replies
CI
Christopher Issac Sunder K
Syncfusion Team
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.
- npm install
- npm install react-scripts --save
- npm start
Please check the sample and let us know whether it fulfills your requirement.
Thanks,
Christo
SD
Sonam Diwate
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
CI
Christopher Issac Sunder K
Syncfusion Team
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SD Sonam Diwate
- Mar 8, 2019 01:06 PM UTC
- Mar 12, 2019 12:52 PM UTC