Closed Gabbosaur closed 3 years ago
you can use this variant https://github.com/dabeng/react-orgchart/blob/master/src/edit-chart/edit-chart.js . In this example you can use JSONDigger and useState for all manipulations with your ds.
is there anyway to call the orgchart and get the current datasource status. e.g. console.log(orgchart.datasource)
is there anyway to call the orgchart and get the current datasource status. e.g. console.log(orgchart.datasource)
I managed to do it with this.
const getHierarchy = async () => {
const hierarchy = await dsDigger.findNodeById("{ROOT-NODE-ID}");
console.log(JSON.stringify(hierarchy));
};
where ROOT-NODE-ID is the id of your root's node. Then you can call the function getHierarchy anywhere you prefer and it prints out the datasource.
@Gabbosaur thanks , forgot to mention that i am using react. and i understand thats not available in that version?
@Gabbosaur thanks , forgot to mention that i am using react. and i understand thats not available in that version?
That's right. You can use the function I previously posted to get the datasource, and yes I also have used React. Hope that helps!
Hi, is there a way to export the datasource upon adding/deleting/updating the chart? I saw on the jQuery version that there is a method called getHierarchy(), which is what I am looking for. But there is no such method in this react version. Does anyone have any suggestion? Thanks.