Skip to Content

Unable to populate data in SAP UI5 link

Hi Experts,

As we all know,

oModel read() function returns two parameters i.e. oData,response.

My oData is

Now i want to use the text as a link in my application.

<List headerText="Attachment list" id="al">
		<CustomListItem>
			<HBox>
				<VBox class="sapUiSmallMarginBegin sapUiSmallMarginTopBottom">
					<Link text="{/results(0)/text}" press="handlePress" />
				</VBox>
			</HBox>
		</CustomListItem>
	</List>

I created json model from odata and then used setModel() to set model of list, but still am unable to get any result in list.

Please help.

I will be really thankful to you.

Regards,

Ankit

1.png (5.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 14, 2017 at 07:10 AM

    Hi,

    Do as following.

    // In Controller: call success
    oJson = new sap.ui.model.json.JSONModel(oData);
    this.getView().setModel(oJson, "MdlName");
    
    // In View
    <List headerText="Attachment list" id="al" items="{MdlName>/results}">
    	<CustomListItem>
    		<HBox>
    			<VBox class="sapUiSmallMarginBegin sapUiSmallMarginTopBottom">
    				<Link text="{MdlName>text}" press="handlePress" />
    			</VBox>
    		</HBox>
    	</CustomListItem>
    </List>
    
    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      text="{/results(0)/text}"

      This statement binds only first item. and it's declaration should go as follows

      text="{/results/0/text}"

      In case of list, you have to bind to items. Then it'll form no of rows based on no of records.