cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CustomData attribute (data-) not working as documented on XML

DanFilho
Explorer
0 Kudos
336

Hello,

I'm finding some trouble in SAPUI5 to get `data-` attributes written to DOM. I need a simple implementation as I will need to manually add in several XML elements this data attribute

I'm aware that I could use `<CustomData />`, but the perfect implementation for my need is to create a new XML namespace for http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1 and then evoke it on the element, as in:

<Button namespace:testid="foobar" />

 The problem is that it's not rendering on DOM and I just can't find any more ways to tackle this on the documentation, and even here.

This is a short example of my implementation, and the problem: https://jsfiddle.net/kpvnw760/4/

If you notice, once you run the code linked above, and if you do:

document.querySelector("button").dataset

It will only list "sapUI" and "ui5Accesskey", never "testId" nor "foobar".

The documentation reference I'm using is: https://ui5.sap.com/#/topic/91f0c3ee6f4d1014b6dd926db0e91070 (section: "Use in XML Views").

 

Thank you a lot, in advance!

Accepted Solutions (0)

Answers (1)

Answers (1)

TrusPatel
Participant

The reason is that Shorthand for customdata does not write those attributes to DOM.

https://ui5.sap.com/#/topic/1ef9fefa2a574735957dcf52502ab8d0 

   To set the writeToDom flag in XML views, the aggregation has to be written in expanded notation.

 

I am also looking for a solution to this.

 
DanFilho
Explorer
0 Kudos
I'm happy to file a formal request or even to try to implement this. Do you know where I can suggest/open suggestion issues for UI5 in an effective way?