I am using sap.m.Select
as a select option for a user and it looks like this:
<Select
forceSelection="false"
selectedKey="{Priority}"
items="{
path: '/PRIORITY_DDSet',
formatter: '.formatter.convert',
sorter: {
path: 'Value'
}
}"
>
<core:Item
key="{
path:'Id',
formatter: '.formatter.convert',
type: 'Integer'
}"
text="{Value}"
/>
</Select>
As a model, ODataModel
is used. The problem is: when change on the sap.m.Select
happens, the string key is bound to the OData model like this:
However, the definition of the OData model states, that Priority
should be of type Integer
.
As you can see in the definition of the Select
, I tried to use formatter
for the key
as well as the type Integer
. I also tried to use sap.ui.model.type.Integer
as a type but without success. I checked, and the formatter function is called only when loading the Select
. When selection is changed in the Select
, the formatter function is not called.
Is there a way to do this in XML? Or do I need to code this e.g. in selection changed event?
Remove formatters and add type: 'sap.ui.model.type.Integer'
to selectedKey:
<Select
forceSelection="false"
selectedKey="{path: 'Priority', type: 'sap.ui.model.type.Integer'}"
items="{ path: '/PRIORITY_DDSet', sorter: { path: 'Value' } }">
<core:Item
key="{path:'Id'}"
text="{Value}"/>
</Select>
I'm not sure if that's the reason but value of the Priority
property can be used without any extra coding like type conversion to save with e.g. ODataModel.submitChanges()