Skip to Content

Network Graph crashes when using delete node with OData Model

Hi All,

I am using Network Graph control with OData model bindings and it works well. I added a custom action button of 'Delete' on Nodes which trigger DELETE call to SAP to delete that node. With the delete call, OData model automatically fetches the Nodes again and it crashes the Graph at this point. I get duplicate ID error in my console.

Could someone please help me here?

BR, Ekansh

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Apr 07 at 07:54 AM

    I just removed the custom action buttons from XML view and added those in controller inside AfterLayouting event handler function and it works.

    onAfterLayouting: function (oGraph) {
    			this.oGraph.preventInvalidation(true);
    			var aNodes = oGraph.getNodes() || [];
    			//add action buttons per NodeType
    			for (var i = 0; i < aNodes.length; i++) {
    				var oNode = aNodes[i];
    				switch (oNode.getBindingContext().getProperty("NodeType")) {
    				case "PARTNER":
    					//detail button
    					oNode.addActionButton(new ActionButton({
    						icon: this._teamViewModel.getProperty("/detailBtnIcon"),
    						title: this.getText("Tooltip.Details"),
    						tooltip: this.getText("Tooltip.Details"),
    						press: function (oEvent) {
    							this.onPressNodeDetail(oEvent);
    						}.bind(this)
    					}));
    					//delete button
    					oNode.addActionButton(new ActionButton({
    						icon: this._teamViewModel.getProperty("/deleteBtnIcon"),
    						title: this.getText("Tooltip.Delete"),
    						tooltip: this.getText("Tooltip.Delete"),
    						press: function (oEvent) {
    							this.onPressNodeDelete(oEvent);
    						}.bind(this)
    					}));
    					break;
    				case "PROJECT":
    					//add partner button
    					oNode.addActionButton(new ActionButton({
    						icon: this._teamViewModel.getProperty("/addBtnIcon"),
    						title: this.getText("Tooltip.AddPartner"),
    						tooltip: this.getText("Tooltip.AddPartner"),
    						press: function (oEvent) {
    							this.onPressAddPartner(oEvent);
    						}.bind(this)
    					}));
    					break;
    				case "PRODUCT":
    					//add partner button
    					oNode.addActionButton(new ActionButton({
    						icon: this._teamViewModel.getProperty("/addBtnIcon"),
    						title: this.getText("Tooltip.AddPartner"),
    						tooltip: this.getText("Tooltip.AddPartner"),
    						press: function (oEvent) {
    							this.onPressAddPartner(oEvent);
    						}.bind(this)
    					}));
    					break;
    				default:
    				}
    			}
    			this.oGraph.preventInvalidation(false);
    		},
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.