Skip to Content

Table shows only one entry from bound XML model whereas more entries are present in XML model

Hello Experts,

I am trying to bind the rows of a UI5 with a XML model. The problem is, even though I have two entries in the XML data, the table only shows the first entry.

Code for Table:

var  oTable = new sap.ui.table.Table("myTab",{               columns : [               {label: "Category", template: "d:CategoryName"},              {label: "Name", template: "d:ProductName" },              {label: "Sales", template: "d:ProductSales"}              ]          });

Code for DataBinding:

var oModel = new sap.ui.model.xml.XMLModel();var xmldata  = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'+            '<feed xml:base="http://services.odata.org/Northwind/Northwind.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">'+              '<entry>'+              '<content type="application/xml">'+              '<m:properties>'+        '<d:CategoryName>Beverages</d:CategoryName>'+        '<d:ProductName>Chang</d:ProductName>'+        '<d:ProductSales m:type="Edm.Decimal">7038.5500</d:ProductSales>'+        '</m:properties>'+              '</content>'+            '</entry>'+            '<entry>'+              '<content type="application/xml">'+              '<m:properties>'+        '<d:CategoryName>Beverages1</d:CategoryName>'+        '<d:ProductName>Chang1</d:ProductName>'+        '<d:ProductSales m:type="Edm.Decimal">8198.5500</d:ProductSales>'+        '</m:properties>'+              '</content>'+            '</entry>'+            '</feed>' ;         oModel.setXML(xmldata);            oTable = sap.ui.getCore().byId("myTab");         oTable.setModel(oModel );            oTable.bindRows("/entry/content/m:properties");

What could be the reason of error?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on May 31, 2013 at 09:45 PM

    Hi Atanu,

    just use for the data binding:

    var  oTable = new sap.ui.table.Table("myTab",{                 columns : [                 {label: "Category", template: "content/m:properties/d:CategoryName"},                {label: "Name", template: "content/m:properties/d:ProductName" },                {label: "Sales", template: "content/m:properties/d:ProductSales"}                ]            }); 

    and

               oTable.bindRows("/entry"); 

    to bind the aggregation.

    To find more information on xml models just check the Developer Guide.

    Regards, Frank

    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.