cancel
Showing results for 
Search instead for 
Did you mean: 

Network Graph crashes when using delete node with OData Model

EkanshCapgemini
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

EkanshCapgemini
Active Contributor
0 Kudos

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);
		},

Answers (0)