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

user3624736

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. 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');
        }
    }
});

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?

Haojie

var data = m.getData();

data is not an Array. It is a XML document.

To remove an entry from the document:

var root = data.childNodes[0];
var aEntry = root.getElementsByTagName("entry");
root.removeChild(aEntry[idx]);

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I hide the columns of a TreeTable in SAPui5

分類Dev

I want to delete row from both table

分類Dev

SAPUI5 TwoWay Binding to XMLModel with button Custom Data property not update model

分類Dev

How can I delete display style from all children when I filter from bootstrap?

分類Dev

Incompatible types when I used delete from the list in REST API

分類Dev

How can I row bind the unmatch data in the column of first table from the second table

分類Dev

How can "on delete restrict" be used in a model?

分類Dev

How can I delete/edit row in JTable and MySQL using hibernate?

分類Dev

Why can't I delete labels from a table cell on storyboard?

分類Dev

How can I get a count of a model from another model in Django?

分類Dev

Getting exception when trying to delete a line from a text file. How can i solve it?

分類Dev

How can I capture a table row press action in Swift WatchKit?

分類Dev

How can I update 1 row of an sql table using php?

分類Dev

How can I apply a drop shadow to the bottom of a table row on hover

分類Dev

How can I create a view where each row in one table is treated as a child of each row in another table?

分類Dev

How do I pass an Image in the body of a OData Request in SAPUI5?

分類Dev

SAPUI5 model sorter sort responsive table by multiple columns

分類Dev

How can I delete a file from a Git repository?

分類Dev

How can I delete a folder from the firebase storage?

分類Dev

How can I delete an node from a linked list with a single pointer?

分類Dev

How can i delete previous BufferedImages from Graphics stack in Java?

分類Dev

Can I delete an element from an HDF5 dataset?

分類Dev

How can I model OTHER_FILES from qmake with CMake?

分類Dev

How can I get other fields from relation model?

分類Dev

How can I find the minimum value from duplicate row numbers?

分類Dev

How can I "open" a file from WSL with the default application?

分類Dev

How I can Delete a row in Access with its ID number(autonumber)? in C#

分類Dev

How can I get first 5 and last 1 records from table mysql?

分類Dev

How can I get column names from a table in Oracle?

Related 関連記事

  1. 1

    How can I hide the columns of a TreeTable in SAPui5

  2. 2

    I want to delete row from both table

  3. 3

    SAPUI5 TwoWay Binding to XMLModel with button Custom Data property not update model

  4. 4

    How can I delete display style from all children when I filter from bootstrap?

  5. 5

    Incompatible types when I used delete from the list in REST API

  6. 6

    How can I row bind the unmatch data in the column of first table from the second table

  7. 7

    How can "on delete restrict" be used in a model?

  8. 8

    How can I delete/edit row in JTable and MySQL using hibernate?

  9. 9

    Why can't I delete labels from a table cell on storyboard?

  10. 10

    How can I get a count of a model from another model in Django?

  11. 11

    Getting exception when trying to delete a line from a text file. How can i solve it?

  12. 12

    How can I capture a table row press action in Swift WatchKit?

  13. 13

    How can I update 1 row of an sql table using php?

  14. 14

    How can I apply a drop shadow to the bottom of a table row on hover

  15. 15

    How can I create a view where each row in one table is treated as a child of each row in another table?

  16. 16

    How do I pass an Image in the body of a OData Request in SAPUI5?

  17. 17

    SAPUI5 model sorter sort responsive table by multiple columns

  18. 18

    How can I delete a file from a Git repository?

  19. 19

    How can I delete a folder from the firebase storage?

  20. 20

    How can I delete an node from a linked list with a single pointer?

  21. 21

    How can i delete previous BufferedImages from Graphics stack in Java?

  22. 22

    Can I delete an element from an HDF5 dataset?

  23. 23

    How can I model OTHER_FILES from qmake with CMake?

  24. 24

    How can I get other fields from relation model?

  25. 25

    How can I find the minimum value from duplicate row numbers?

  26. 26

    How can I "open" a file from WSL with the default application?

  27. 27

    How I can Delete a row in Access with its ID number(autonumber)? in C#

  28. 28

    How can I get first 5 and last 1 records from table mysql?

  29. 29

    How can I get column names from a table in Oracle?

ホットタグ

アーカイブ