on 2024 Sep 05 3:12 PM
Hi,
I need to assigned an object to a CustomData value and as specified in the documentation that's possible as long as not written to html. So, this seems to be working both in XML and JS:
<Input>
<customData>
<core:CustomData key="myCustomData" value="{ myProperty: 'myValue' }"/>
</customData>
</Input>
new sap.m.Input({
customData: [
new sap.ui.core.CustomData({ key: "myCustomData", value: { myProperty: 'myValue' } }),
],
});
Result:
{
"myCustomData": {
"myProperty": "myValue"
}
}
But, I am having issues due to conflicts with the binding related object property names, such as 'path'. So for example, if I replace 'myProperty' with 'path', the result is:
<Input>
<customData>
<core:CustomData key="myCustomData" value="{ path: 'myValue' }"/>
</customData>
</Input>
{
"myCustomData": null
}
For XML, it looks like I can overcome this by using the same approach as for the documented SmartTable p13nData, and escape the object so it's stringified:
<Input>
<customData>
<core:CustomData key="myCustomData" value='\{"path": "myValue"}'/>
</customData>
</Input>
{
"myCustomData": "{\"path\": \"myValue\"}"
}
But for JS, I cannot figure out how to do it to keep it a string:
new sap.m.Input({
customData: [
new sap.ui.core.CustomData({ key: "myCustomData", value: JSON.stringify({ path: 'myValue' }) }),
],
});
{
"myCustomData": null
}
I am not sure whether doing this is bad or not and also afraid of other possible conflicts in the future (if my object property name becomes a binding relevant name).
this worked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.