Search code examples
data-bindingsapui5

SAPUI5 - bind data into SimpleForm


I'm trying to bind data inside a Simple form after a Omodel.read, this is my code:

oModel.read("/" + sObjectPath + "/to_AL", {
    success: function(oData2, oResponse2) {
        var oModelJson = new sap.ui.model.json.JSONModel(oData2.results[0]);                             
        that.getView().byId("SimpleFormAnalisi").setModel(oModelJson);
    }
}

oData2.results[0] contains the data I want to bind, SimpleFormAnalisi is the name of my SimpleForm

<form:SimpleForm id="SimpleFormAnalisi" 
    editable="false" 
    layout="ResponsiveGridLayout" 
    labelSpanXL="4" 
    labelSpanL="4"
    labelSpanM="12" 
    labelSpanS="12" 
    adjustLabelSpan="false" 
    emptySpanXL="0" 
    emptySpanL="0" 
    emptySpanM="0" 
    emptySpanS="0" 
    columnsXL="2"
    columnsL="2" 
    columnsM="2" 
    singleContainerFullSize="false">
    <form:content>
        <Label text="SST"  textDirection="RTL"/>
        <Text text="{sst}" />

I expected into {sst} the value, but is empty.

any help? best regarsd


Solution

  • Nearly everything you are doing in your example is correct. What might be the problem is the databinding in your Text element.

    Please take a look at the docs, to make sure that your binding syntax is right. JSON models require a / binding, which you don't have.