on 07-28-2019 11:15 AM
I have created a full-stack app in Web IDE. I created:
All is OK, except I have now added a column to the table that users a Select control. Here is the XML code:
<m:Select
enabled="true"
editable="true"
forceSelection="false"
selectedKey="{status}"
items="{ path: 'actions>/Actions' }">
<c:Item key="{actions>key}" text="{actions>label}"/>
</m:Select>
And here is the controller code.
initActions: function () {
var actions = {"Actions" : [
{key: 0, label: ""},
{key: 1, label: "Keep"},
{key: 2, label: "Migrate"},
{key: 3, label: "Delete"}
]};
var oModel = new sap.ui.model.json.JSONModel(actions);
this.getView().setModel(oModel, "actions");
}
When I view the data, and if I change the data directly in the database, I get the right values in the Select box. But if I change the select box and click Save, it does not save the values (in fact, at this point, it doesn;t save any of the data).
I have a default data model (OData data source), whose field is status. The second model holds the choices for the Select control.
Any idea?
Seems that I need to set the type, since the key in the control is stored as a String but my data type is integer.
<m:Select enabled="true" forceSelection="false" selectedKey="{path: 'status', type: 'sap.ui.model.type.Integer'}" items="{ path: 'actions>/Actions' }" change="selectChange">
<c:Item key="{actions>key}" text="{actions>label}"/>
</m:Select>
Thanks to pcatano on his post on stackoverflow
https://stackoverflow.com/questions/48145178/sap-m-select-bind-key-as-integer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.