OrgChart icon indicating copy to clipboard operation
OrgChart copied to clipboard

getHierarchy( includeNodeData =true ) returns edited hierarchy but not edited node content

Open Monkeytactics opened this issue 4 years ago • 3 comments

I've implemented a 'b2t' version of this and it mostly works great. However, I added contentEditable =true to two node div's:

  1. content
  2. note (this is an extra div/JSON element I added to allow users to comment on a relationship)

Unfortunately getHierarchy( includeNodeData ) only returns modified structure detail, this I am able to save just fine, but the modified node content is seemingly ignored by this method.

I can't find any reference to editing and saving content in addition to hierarchy, perhaps other users aren't doing this - perhaps I am missing something - is there a way to do this in the current codebase or do I need to add this functionality myself?

Monkeytactics avatar Sep 16 '21 15:09 Monkeytactics

For clarity here - this method does return node data for me, as opposed to just id's with the 'includeNodeData' omitted - but it ignores any data content additions or edits and returns only data state at the point the orgchart was generated (including structure changes, if applicable).

Monkeytactics avatar Sep 16 '21 15:09 Monkeytactics

For the benefit of others, I'm now using this to get node elements (that may have been edited) from the node tree:

var updates = $('div.node').map(function() { return { id: $(this).attr("id"), content: $(this).find('div.content').text(), note: $(this).find('div.note').text() }; }).get();

This gives me node content as it currently stands, you then just need to parse the getHierarchy(includeNodeData) result and update values with the result of above.

Monkeytactics avatar Sep 16 '21 16:09 Monkeytactics

Hi Monkey. I am fashionably late to this party with developing something similar and have hit the same issue. Outputting to PNG and PDF works fine, but the hierarchy remains unchanged. Would be great if the changed content could be reflected automatically.

Been doing some digging and came across your issue. Just wondering how you implement the merging of the updates variable into the main hierarchy. Did you just identify the changed nodes or update the whole hierarchy?

erased1091 avatar Dec 07 '22 15:12 erased1091