<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OData binding problem with types in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-binding-problem-with-types/m-p/12269614#M1987713</link>
    <description>&lt;P&gt;So, I have an xml view, and a table with some columns in it. I do the odata connecting (V4) in the controller.js, and with the table id I bind the data to the sap.m.table. If I know right, odata binding will get the type of the data from the metadata, which is fine, but I get the following error all the time:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;FormatException in property 'text' of 'Element sap.m.Text#idView1--text0-idView1--table0-0': Type 'sap.ui.model.odata.type.Raw' does not support formatting
Hint: single properties referenced in composite bindings and within binding expressions are automatically convertedinto the type of the bound control property, unless a different 'targetType' is specified. targetType:'any' may avoidthe conversion and lead to the expected behavior. -&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;No matter what the Edm type is (String or Int32)&lt;BR /&gt;&lt;BR /&gt;In js view I can define the type I need, but in xml I can not find the right way.&lt;BR /&gt;There is my view.xml:&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:commons="sap.ui.commons" xmlns:table="sap.ui.table"
        controllerName="sapodatawithxmlview.View" xmlns:html="http://www.w3.org/1999/xhtml"&amp;gt;
    &amp;lt;Shell&amp;gt;
        &amp;lt;App&amp;gt;
            &amp;lt;pages&amp;gt;
                
                &amp;lt;Page id="page" title="{i18n&amp;gt;title}"&amp;gt;
                &amp;lt;content&amp;gt;

                    &amp;lt;Table noDataText="Drop column list items here and columns in the area above" id="table0" items="{/ac4ypersistentchildodata}"&amp;gt;
                        &amp;lt;items&amp;gt;
                            &amp;lt;ColumnListItem type="Active" id="item0"&amp;gt;
                                &amp;lt;cells&amp;gt;
                                    &amp;lt;Text id="text0" text="{id}"/&amp;gt;
                                    &amp;lt;Text id="text1" text="{name}"/&amp;gt;
                                    &amp;lt;Text xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="text1_copy5" text="{createdAt}"/&amp;gt;
                                    &amp;lt;/cells&amp;gt;
                            &amp;lt;/ColumnListItem&amp;gt;
                        &amp;lt;/items&amp;gt;
                        &amp;lt;columns&amp;gt;
                            &amp;lt;Column id="column0"&amp;gt;
                                &amp;lt;header&amp;gt;
                                    &amp;lt;Label text="ID" id="label0"/&amp;gt;
                                &amp;lt;/header&amp;gt;
                            &amp;lt;/Column&amp;gt;
                            &amp;lt;Column xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="column0_copy"&amp;gt;
                                &amp;lt;header&amp;gt;
                                    &amp;lt;Label text="Name" id="label0_copy"/&amp;gt;
                                    
                                &amp;lt;/header&amp;gt;
                                
                            &amp;lt;/Column&amp;gt;
                            &amp;lt;Column xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="column0_copy2"&amp;gt;
                                &amp;lt;header&amp;gt;
                                    &amp;lt;Label text="Registration Date" id="label0_copy2"/&amp;gt;
                                    
                                &amp;lt;/header&amp;gt;
                           &amp;lt;/Column&amp;gt;
                            &amp;lt;/columns&amp;gt;&amp;lt;/Table&amp;gt;
                &amp;lt;/content&amp;gt;
                &amp;lt;/Page&amp;gt;

            &amp;lt;/pages&amp;gt;
        &amp;lt;/App&amp;gt;
    &amp;lt;/Shell&amp;gt;
&amp;lt;/core:View&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;and the controller onInit method:&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;onInit: function() {
        var oModel = new sap.ui.model.odata.v4.ODataModel({
            groupId: "$direct",
            synchronizationMode: "None",
            serviceUrl: "https://localhost:44315/odata/"
        });
            oModel.setDefaultBindingMode("OneWay");
        var oTable = this.byId("table0");
        oTable.setModel(oModel);
},

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thank you any help in advance!!!&lt;/P&gt;</description>
    <pubDate>Tue, 11 Aug 2020 13:13:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2020-08-11T13:13:10Z</dc:date>
    <item>
      <title>OData binding problem with types</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-binding-problem-with-types/m-p/12269614#M1987713</link>
      <description>&lt;P&gt;So, I have an xml view, and a table with some columns in it. I do the odata connecting (V4) in the controller.js, and with the table id I bind the data to the sap.m.table. If I know right, odata binding will get the type of the data from the metadata, which is fine, but I get the following error all the time:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;FormatException in property 'text' of 'Element sap.m.Text#idView1--text0-idView1--table0-0': Type 'sap.ui.model.odata.type.Raw' does not support formatting
Hint: single properties referenced in composite bindings and within binding expressions are automatically convertedinto the type of the bound control property, unless a different 'targetType' is specified. targetType:'any' may avoidthe conversion and lead to the expected behavior. -&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;No matter what the Edm type is (String or Int32)&lt;BR /&gt;&lt;BR /&gt;In js view I can define the type I need, but in xml I can not find the right way.&lt;BR /&gt;There is my view.xml:&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:commons="sap.ui.commons" xmlns:table="sap.ui.table"
        controllerName="sapodatawithxmlview.View" xmlns:html="http://www.w3.org/1999/xhtml"&amp;gt;
    &amp;lt;Shell&amp;gt;
        &amp;lt;App&amp;gt;
            &amp;lt;pages&amp;gt;
                
                &amp;lt;Page id="page" title="{i18n&amp;gt;title}"&amp;gt;
                &amp;lt;content&amp;gt;

                    &amp;lt;Table noDataText="Drop column list items here and columns in the area above" id="table0" items="{/ac4ypersistentchildodata}"&amp;gt;
                        &amp;lt;items&amp;gt;
                            &amp;lt;ColumnListItem type="Active" id="item0"&amp;gt;
                                &amp;lt;cells&amp;gt;
                                    &amp;lt;Text id="text0" text="{id}"/&amp;gt;
                                    &amp;lt;Text id="text1" text="{name}"/&amp;gt;
                                    &amp;lt;Text xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="text1_copy5" text="{createdAt}"/&amp;gt;
                                    &amp;lt;/cells&amp;gt;
                            &amp;lt;/ColumnListItem&amp;gt;
                        &amp;lt;/items&amp;gt;
                        &amp;lt;columns&amp;gt;
                            &amp;lt;Column id="column0"&amp;gt;
                                &amp;lt;header&amp;gt;
                                    &amp;lt;Label text="ID" id="label0"/&amp;gt;
                                &amp;lt;/header&amp;gt;
                            &amp;lt;/Column&amp;gt;
                            &amp;lt;Column xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="column0_copy"&amp;gt;
                                &amp;lt;header&amp;gt;
                                    &amp;lt;Label text="Name" id="label0_copy"/&amp;gt;
                                    
                                &amp;lt;/header&amp;gt;
                                
                            &amp;lt;/Column&amp;gt;
                            &amp;lt;Column xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="column0_copy2"&amp;gt;
                                &amp;lt;header&amp;gt;
                                    &amp;lt;Label text="Registration Date" id="label0_copy2"/&amp;gt;
                                    
                                &amp;lt;/header&amp;gt;
                           &amp;lt;/Column&amp;gt;
                            &amp;lt;/columns&amp;gt;&amp;lt;/Table&amp;gt;
                &amp;lt;/content&amp;gt;
                &amp;lt;/Page&amp;gt;

            &amp;lt;/pages&amp;gt;
        &amp;lt;/App&amp;gt;
    &amp;lt;/Shell&amp;gt;
&amp;lt;/core:View&amp;gt;

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;and the controller onInit method:&lt;BR /&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;onInit: function() {
        var oModel = new sap.ui.model.odata.v4.ODataModel({
            groupId: "$direct",
            synchronizationMode: "None",
            serviceUrl: "https://localhost:44315/odata/"
        });
            oModel.setDefaultBindingMode("OneWay");
        var oTable = this.byId("table0");
        oTable.setModel(oModel);
},

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thank you any help in advance!!!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 13:13:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-binding-problem-with-types/m-p/12269614#M1987713</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-08-11T13:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: OData binding problem with types</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-binding-problem-with-types/m-p/12269615#M1987714</link>
      <description>&lt;P&gt;That's right. The v4.ODataPropertyBinding adds a corresponding data type according to the EDM Type from the `$metadata` document. See &lt;STRONG&gt;&lt;A href="https://stackoverflow.com/a/62884400/5846045" target="test_blank"&gt;https://stackoverflow.com/a/62884400/5846045&lt;/A&gt;&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Consequently, apply &lt;STRONG&gt;targetType: 'any'&lt;/STRONG&gt; to those OData property binding infos to turn the automatic type determination off. E.g.:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;cells&amp;gt;
  &amp;lt;Text text="{ path: 'id', targetType: 'any', formatter: '.format' }" /&amp;gt;
  &amp;lt;!-- ... --&amp;gt;
&amp;lt;/cells&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;format: function(value) {
  const formattedValue = /*Do something with the fn parameter(s)*/;
  return formattedValue;
},&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As shown above, you can optionally add a custom formatter to the controller to display the value correctly in the UI.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Aug 2020 15:56:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-binding-problem-with-types/m-p/12269615#M1987714</guid>
      <dc:creator>boghyon</dc:creator>
      <dc:date>2020-08-13T15:56:34Z</dc:date>
    </item>
  </channel>
</rss>

