addModelChangedListener is working but data not storing into database

hi,
i need to do both tree and diagram in two different angular2 components.i am following the following sample http://gojs.net/latest/samples/regroupingTreeView.html. but in this example he was using same html page and included two divs. but i need divs in two different angular2 components. here i am facing one issue if i use addModelChangedListener both the components are listening but the data was not storing in database. can any one help me to solve this issue?

Having the two Diagrams be in two separate components because their respective DIV elements are in different components shouldn’t be a problem, as long as they are both in the same page and are able to communicate.

What is the actual problem?

both diagrams communicate well but the issue is whenever i drag icon into drawing area the icon will be adding into tree perfectly but that data was not stored into database because of AddModelChangedListener. if i remove this listener it was storing into database but tree was not modifying. after refreshing only it was modifying.

How and when are you deciding to “store into the database”?

while dropping into drawing area the data will be store in database using externalObjectDroppedListener, as well as modify in Tree. but only one action is working.

if i load the diagram again it has to load jsonData From Database and populate into Drawing area

I think you’re going to have to step through your code.

Be sure to use the Debug version of the library, go-debug.js and watch the console log for any warnings or errors.

Hi Walter,
From this example http://gojs.net/latest/samples/regroupingTreeView.html. Copy and paste some nodes and hit save button. Newly added nodes are not added to Diagram model. Can You explain me why it is not adding to model.

Ah, thanks for reporting that bug in the Regrouping Tree View sample. We’ll look into fixing that.

Hi Walter,
After solving this bug please let me know. Thanks.

Hi Walter,
I have solved this issue by removing following lines from tree.addModelChangedListener.

if (e.change === go.ChangedEvent.Insert && e.propertyName === “nodeDataArray”) {
// pretend the new data isn’t already in the nodeDataArray for myTreeView
myTreeView.model.nodeDataArray.splice(e.newParam, 1);
// now add to the myTreeView model using the normal mechanisms
myTreeView.model.addNodeData(e.newValue);
}

Is this right way to do it?

Hi Walter,
Is this bug solved in latest release?

Ah, sorry about that. I thought that the fix was already checked in and it would have appeared in the latest release, but that apparently was not the case.

I have updated the sample and put a copy at http://gojs.net/temp/regroupingTreeView.html

Sorry, I am not able to view the page which You have shared.

Thanks Walter

Hi Walter,
The model which you shared working fine.
I have combined http://gojs.net/latest/samples/regrouping.html and http://gojs.net/temp/regroupingTreeView.html as https://plnkr.co/edit/ttoh685UbZXunTwuJOHa?p=preview which contains palette, diagram area, tree view area
In that palette lightblue is group and lightgreen,yellow is node
In this I am trying to generate a “GUID” (bascially a string contains more than 10-15 characters) for node key while dropping the node from palette using the ExternalObjectsDropped listener event.
The Problem is If I Create guid to node key, the tree view hirerachy list is not working . The tree hierarchy is working after I have externally clicked save and load button.
Can you guide me through this issue?.

You need to make sure that for each Model that you create, before you add node data to it that do not already have good node key values, that you set http://gojs.net/latest/api/symbols/Model.html#makeUniqueKeyFunction to a function that returns GUID strings.

By the documentation guidance I have used model.setKeyForNodeData and but After using this also tree hierarchy not working and that makeUniqueKeyFunction not event calling.

Let the model assign node keys automatically, and you won’t have to deal with modifying them in two different models.

I need to generate guid for node data key. If I generate guid for node data key, Tree view is not working.
I have tried that makeuniquekey logic also it’s not working.
Please look at this example https://plnkr.co/edit/ttoh685UbZXunTwuJOHa?p=preview and guide me to create guid which must reflect the tree hierarchy.