Skip to Content
author's profile photo Former Member
Former Member

How can I delete a row from a Table in SAPUI5 Application when I used Model as XMLModel?

I have created SAPUI5 application, in that I have loaded data from external .xml file into a table, it was fine. Now, I am trying to delete a specific row from that table.But, I am getting error at the line: `var removed = data.splice(idx, 1);`. However, the same code is good for when model is JSON. How can I delete a specific row from a table when model XMLModel?

Please suggest me to proceed good.

For this purpose, I use this code:

var oModel = new sap.ui.model.xml.XMLModel();

oModel.loadData("Deployments.xml", "", false);


oTable.bindRows("/service"); // here "service" is the root element of xml file

var oTable= new sap.ui.commons.Button({text:"Delete Service",

press : function() {

var idx = oTable.getSelectedIndex();

if (idx !== -1) {

var m = oTable.getModel();

var data = m.getData();

var removed = data.splice(idx, 1); // error showing at this line

m.setData(data);[0]) + 'is removed');

} else {'Please select a row');





Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 30, 2014 at 01:29 PM


    The sap.m.Table has property "mode" which can be set to "delete".

    Then you can define the functionality in "delete" event of the ListItemBase .

    For more info refer to this link:

    SAPUI5 SDK - Demo Kit



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 11, 2015 at 01:33 PM


    //To delete a row from table

    onDelete: function(oEvent){

    var m = oEvent.getSource().getParent();

    var tbl = this.getView().byId("TableID");

    var idx = m.getBindingContextPath();

    idx = idx.charAt(idx.lastIndexOf('/')+1);

    if (idx !== -1) {

    var a = tbl.getModel(); // if named model - var a= tbl.getModel(ModelName);

    var data = a.getData();

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

    // Check return value of data.

    // If data has an hierarchy. Ex: data.results

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





    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.