Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SAPUI - XML View - complex type information

Hi,

I have some issues to express my type information in XML views.

The JS view would look like:

new sap.m.Text({

     text: {

          path:"/number",

          type: new sap.ui.model.type.Integer({groupingEnabled: true, groupingSeparator: '.'})

          }

     })

My current XML view looks like this:

<Text text="{path:'/number', type:'sap.ui.model.type.Integer', constraints:{groupingEnabled: true, groupingSeparator: '.'}}" />

or

<Text text="{path:'/number', type:'sap.ui.model.type.Integer({groupingEnabled: true, groupingSeparator: '.'})'}" />

or several other ideas, e.g. escpaing of the additional '.

But nothing worked. And I could not find any documentation of how it might work.

The diagnostic tool translates JS to XML, yes, but it ignores the complicated case. :-(

I could use a formatter to group myself, but there are several cases, where I need such complicated XML views.

E.g. if I want to use multiply paths as an array.

In my index.html I added data-sap-ui-xx-bindingSyntax="complex".

Hope you can help me out.

Thanks and bests

-Ben

Former Member
Former Member replied

Hi Ben,

          This should work

<!DOCTYPE html>

<html><head>

  <meta http-equiv='X-UA-Compatible' content='IE=edge' />

  <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

  <title>Mobile App with XML View with JSON Data</title>

<script id='sap-ui-bootstrap' type='text/javascript'

   src='/sapui5-internal/resources/sap-ui-core.js'

   data-sap-ui-theme='sap_bluecrystal'

   data-sap-ui-libs='sap.m'

   data-sap-ui-xx-bindingSyntax='complex'></script>

  <script id="myXml" type="text/xmldata">

   <mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="myController" displayBlock="true">

   <App>

  <Page title="Hello">

  <Text text="{path:'/1/r', type:'sap.ui.model.type.Integer', formatOptions:{groupingEnabled: true , groupingSeperator : '.'}}" />

  <Button text="{/1/name}" press= "doSomething"/>

  </Page>

   </App>

   </mvc:View>

  </script>

<script>

  sap.ui.controller("myController", {

  onInit: function() {

  var model = new sap.ui.model.json.JSONModel();

  model.setData([

  {lastName: "Dente", name: "Al", r  : 1232323.221212,checked: true, linkText: "www.sap.com", href: "http://www.sap.com", rating: 4},

  {lastName: "Friese", name: "Andy", r  : 111222.221212, checked: true, linkText: "www.spiegel.de", href: "http://www.spiegel.de", rating: 2},

  {lastName: "Mann", name: "Anita",  r  : 1.221212,checked: false, linkText: "www.kicker.de", href: "http://www.kicker.de", rating: 3}

  ]);

  this.getView().setModel(model);

  },

  doSomething: function() {

  alert("Hello World!");

  }

  });

  sap.ui.view({ viewContent: jQuery('#myXml').html(), type:sap.ui.core.mvc.ViewType.XML }).placeAt("content")

</script>

</head>

   <body class='sapUiBody'>

   <div id='content'></div>

</body>

</html>

Thank you.

Regards,

               Pruthvi.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question