Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8065

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

$
0
0

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

      sap.ui.getCore().setModel(oModel);

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

                           sap.m.MessageToast.show(JSON.stringify(removed[0]) +  'is removed');

                       

                         } else {

                           sap.m.MessageToast.show('Please select a row');

                         }

                       }

           

                

                     });

    

Thanks


Viewing all articles
Browse latest Browse all 8065

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>