cancel
Showing results for 
Search instead for 
Did you mean: 

Binding text ObjectAttribute Ui5

Giacomo_Savioli
Explorer
0 Kudos

Hi, i'm new in SapUi5.

in my first page I have an input form, after I click search im going to set model like this:


sap.ui.getCore().setModel(oJsonModel,"VascheDetails");


After I call a new page I want to see the objects of the first row in ObjectHeader. I tried like this


<ObjectHeader

  headerText="Dettagli vasca"

         title="{VascheDetails>/0/Matnr}">

         <attributes>

           <ObjectAttribute title="Materiale" text="" />

           <ObjectAttribute title="Partita" text="" />

           <ObjectAttribute title="Codice Campagna" text="{VascheDetails>/0/Zccam}" />

           <ObjectAttribute title="Data prod. vasca" text="{VascheDetails>/0/Datav}" />

         </attributes>

       </ObjectHeader>

but it doesn't work. How can I solve my problem?

Thank you

Giacomo

Accepted Solutions (0)

Answers (2)

Answers (2)

Private_Member_15166
Active Contributor
0 Kudos
  1. this.getView().setModel(oJSONModel,"VascheDetails") // Declare your model in onInit

    method of controller and then write this

  1. <ObjectHeader 
  2.   headerText="Dettagli vasca" 
  3.          title="{VascheDetails>/0/Matnr}">  // why /0 here??
  4.          <attributes> 
  5.            <ObjectAttribute title="Materiale" text="" /> 
  6.            <ObjectAttribute title="Partita" text="" /> 
  7.            <ObjectAttribute title="Codice Campagna" text="{VascheDetails>/0/Zccam}" /> // why /0 here??
  8.            <ObjectAttribute title="Data prod. vasca" text="{VascheDetails>/0/Datav}" />  // why /0 here??
  9.          </attributes> 
  10.        </ObjectHeader>

Why you have used /0 here?? Is this the actual path?

Is this an oDataModel or JSONModel??

Giacomo_Savioli
Explorer
0 Kudos

I used {VascheDetails>/0/Matnr] because I wanted to access at the first record of results and I have a odata model..

Private_Member_15166
Active Contributor
0 Kudos

Then my first question is:-

  • How you have declared oJSONModel?
  • is it live var oJSONModel = new sap.ui.model.json.JSONModel("URL");
  • If yes then change it to oDataModel like this. oDataModel = new sap.ui.model.odata.ODataModel("URL");
  • then bind your OBJECTHEADER like this.


  1. <ObjectHeader
  2.   headerText="Dettagli vasca"
  3. binding="{VascheDetails>/0}"
  4.          title="{VascheDetails>Matnr}">  // why /0 here??
  5.          <attributes>
  6.            <ObjectAttribute title="Materiale" text="" />
  7.            <ObjectAttribute title="Partita" text="" />
  8.            <ObjectAttribute title="Codice Campagna" text="{VascheDetails>Zccam}" />
  9.            <ObjectAttribute title="Data prod. vasca" text="{VascheDetails>Datav}" /> 
  10.          </attributes>
  11.        </ObjectHeader>
santhu_gowdaz
Active Contributor
0 Kudos

{VascheDetails>/0/Matnr} is not a problem, if your data is coming in that structure. debug your model, then you will come to know your data path.

santhu_gowdaz
Active Contributor
0 Kudos

this.getView().setModel(oJsonModel,"VascheDetails");