cancel
Showing results for 
Search instead for 
Did you mean: 

Problem to bind ObjectListItem

former_member393100
Discoverer
0 Kudos

Hello,

First of all, I'm new in sap Fiori development.

I have an issue to bind one ObjectListItem. I need to get information of one material after input.

I decided to get the data with JSONModel, it works perfectly but when i tried to do

this.getView().setModel(JsonModel, "infos_etq");

nothing is happening..

this is my controller code :

var JsonModel = new sap.ui.model.json.JSONModel();       
var serviceUrl = this.ODataServiceUrl + "/EtiquetteSet('1')";       
JsonModel.loadData(serviceUrl, null, false);         
this.getView().setModel(JsonModel, "infosETQ");

And my view code :

<List items="{/EtiquetteSet}" id="infos_etq">             
<items id="items">               
<ObjectListItem xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core.core" xmlns:tnt="sap.tnt" xmlns:form="sap.ui.layout.form" xmlns="sap.m" title="Infos étiquette">                 
   <attributes>                   
      <ObjectAttribute text="{Matnr}" id="matnr" title="Article"/>                   
      <ObjectAttribute text="{maktx}" id="maktx" title="Description"/>                   
      <ObjectAttribute text="{Charg}" id="charg" title="Lot"/>                   
      <ObjectAttribute text="{vfdat}" id="peremption_date" title="Péremption"/>                   
      <ObjectAttribute text="{Zqty} {Meins}" id="qty" title="Quantité"/>                   
      <ObjectAttribute text="{Zetiq}" id="zetiq" title="Etiquette"/>                 
   </attributes>               
</ObjectListItem>             
</items>           
</List>

Can someone help me with my issue pls ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Hello,

As you are using named model, u need to use model name as well like below :

<List items="{infosETQ>/EtiquetteSet}" id="infos_etq">             
<items id="items">               
<ObjectListItem xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core.core" xmlns:tnt="sap.tnt" xmlns:form="sap.ui.layout.form" xmlns="sap.m" title="Infos étiquette">                 
   <attributes>                   
      <ObjectAttribute text="{infosETQ>Matnr}" id="matnr" title="Article"/>                   
      <ObjectAttribute text="{infosETQ>maktx}" id="maktx" title="Description"/>                   
      <ObjectAttribute text="{infosETQ>Charg}" id="charg" title="Lot"/>                   
      <ObjectAttribute text="{infosETQ>vfdat}" id="peremption_date" title="Péremption"/>                   
      <ObjectAttribute text="{infosETQ>Zqty} {Meins}" id="qty" title="Quantité"/>                   
      <ObjectAttribute text="{infosETQ>Zetiq}" id="zetiq" title="Etiquette"/>                 
   </attributes>               
</ObjectListItem>             
</items>           
</List>

Regards

Rakesh

former_member393100
Discoverer
0 Kudos

Thanks for your answer, i do what you said but the issue is still there. I don't know why but when i put the initial model with all the entries it works and when I try to put the Json model nothing is happening. Maybe the format of the Json model makes problem ?

junwu
Active Contributor
0 Kudos

you have to check what is inside of JsonModel

if you load odata, it probably has structure like d.results

<List items="{infosETQ>/d/results}" id="infos_etq">