cancel
Showing results for 
Search instead for 
Did you mean: 

Adding type information in XML views

UweFetzer_se38
Active Contributor
0 Kudos

With JS views it is possible to add type information to a field, for example:


oControl = new sap.ui.commons.TextField({

     value: {

          path:"/company/revenue",

          type: new sap.ui.model.type.Float({

               minFractionDigits: 2,

               maxFractionDigits: 2

          })

     }

})

See https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/BindingProperties.html

I've tried the same with XML views (according to https://sapui5.hana.ondemand.com/sdk/test-resources/sap/m/demokit/explored/index.html#/code/inputChe... ) without success


Please check my gist example: Binding problems with UI5 and XML views


Am I doing something wrong?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

No, you are doing fine!

The thing that is missing is what the documentation forgets to say.

<script src="resources_path/sap-ui-core.js" id="sap-ui-bootstrap"

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

  data-sap-ui-theme="sap_bluecrystal"

  data-sap-ui-xx-bindingSyntax="complex">

</script>

There is needed to tell the core that you are using a complex binding syntax. I don't know why that is not a default option, but that is the way it is.

Regards,

Luis Alberto

Answers (2)

Answers (2)

UweFetzer_se38
Active Contributor
0 Kudos

Reporting back as promised: it works

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Hi Uwe

Luis is spot on. I had thought you already had that (thought you might have seen my Twitter conversation with Tom Van Doorslaer yesterday 🙂

Nice work on putting the Gist together, btw - was perfect - I had your test app code downloaded and running in my browser in 30 seconds. I had to make a couple of tweaks, perhaps I should write a post on what I did.

For info, the config options are documented in the Developer Guide section of the SDK.

cheers!
dj

UweFetzer_se38
Active Contributor
0 Kudos

Hi DJ,

yes, I've seen the discussion on Twitter, but haven't realized that this is relevant for me (bummer).

Will try the solution tonight and report back.

But as Luis already said, this should be default, else JS and XML views behave different. Or are there problems with performance and/or memory consumption if I'm using this config?

The documentation says:


Note: This functionality is marked as experimental and can be switched on via the configuration flag xx-bindingSyntax=„complex“. The reason is that it is not fully compatible with existing syntax because now you have to escape curly braces {}. Without escaping it is interpreted as extended calculated fields syntax

(yes, there are unicode problems on the site )

Is there an official statement from SAP whether we can/should use this functionality?

Uwe

qmacro
Developer Advocate
Developer Advocate
0 Kudos

I've not seen an official statement. But in any case, for me it's the default, and I even supply it as default in the SublimeUI5 Templates and Snippets, for example:

SublimeUI5/Templates/UI5 XACE - XML App Component EventBus/index.html at master · qmacro/SublimeUI5 ...

and

SublimeUI5/Snippets/indexm.html.sublime-snippet at master · qmacro/SublimeUI5 · GitHub

dj