jgraph / mxgraph

mxGraph is a fully client side JavaScript diagramming library
Other
6.81k stars 2.06k forks source link

Remove Cell Does not work after Loading mxGraph using Decode XML #465

Closed arijitsil closed 3 years ago

arijitsil commented 4 years ago

Once a model is saved , the mxModel xml is saved in Database. So when the user wants to edit that model, I retrieve the model and decode it using the following code

var xmlDocument = mxUtils.parseXml(mxModel); var decoder = new mxCodec(xmlDocument);

var node = xmlDocument.documentElement; decoder.decode(node, graph.getModel()); let elt = xmlDocument.documentElement.firstChild; Beyond this, I have options in the graph to edit the graph further. Like Add,Copy, Delete etc . All the Add Operations are working fine, but the Operations which is are trying to remove cells its not getting reflected in the graph realtime.

So for example for Delete operation, I have the following code bounded under beginUpdate() and endupdate()

graph.getModel().beginUpdate(); graph.removeCellsFromParent([selectedCell]); graph.getModel().remove(e[0]); graph.getModel().remove(selectedCell); graph.getModel().endUpdate(); With this operation, the delete is happening but its not reflected in the screen. I have arrived to this conclusion because when I save the Model and reload it, the deleted cell is no longer there.

I need to show the delete in real time.

PrudhviMadasu commented 4 years ago

Use graph.refresh(); to refresh entire graph and graph.view.refresh(cell); to refresh a cell for changes to reflect