Skip to Content
0

Unable to populate data in SAP UI5 link

Dec 13, 2017 at 11:46 AM

32

avatar image

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Irfan Gokak Dec 14, 2017 at 07:10 AM
0

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>
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Irfan,

Please let me know why the setModel on entire view worked, but same didn't work when i trying to set model of a list.

I hope you will answer my query.

Best regards,

Ankit

0

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.

0