To delete particular row in table in sapui5 using javascript


How to Delete Particular Row on Selection 

Use Following delete code to delete particular row 

View.xml

<Button text="Delete" press="onDelete"></Button>

Controller.js
onDelete : function (oEvent) {

 var oTable = this.getView().byId("idProductsTable");

 var idx = oTable.getSelectedContexts();

 if (idx !== -1) {

var m = oTable.getModel();

var data = oModel.getData();

        var removed = data.splice(idx, 1);

 oModel.setData(data);

alert(JSON.stringify(removed[0]) + 'is removed');

} else {

alert('Please select a row');

 }

}

Post a Comment

Previous Post Next Post