How can I get the JSONModel to get the initial value of the control?

Viewed 59

I am using SAPUI5. I have a form which when submitting adds that data to a new row in a table.

I have a JSONModel bound to various controls in a form, which is then copied to a new model for the sap.m.Table to make a new row entry.

The problem is the model is empty initially, and will only create properties for the control bindings when the value is changed (from entering text, clicking the checkbox, choosing from the dropdown list etc). Otherwise the property won't even exist in the model.

This is particularly noticeable in Select controls. The default top option is selected, but unless you select another option, the resulting property in the jsonmodel won't exist.

To illustrate:
jsonmodel = {}
sap.m.Input value="{model>/input1}"
sap.m.Input value="{model>/input2}"

User enters data into first input field and submits.
jsonmodel = {"input1": "xyz"}
No value for "input2"

How can this issue be fixed? I don't want to create the model with all the properties explicitly, and set them to a blank value. Is there a way the model can know the values it is bound to and include them automatically without the need for manually changing it first?

0 Answers
Related