on 11-18-2013 9:38 AM
Hi,
I have developed sample split app Application using Public Gateway Service.
https://sapes1.sapdevcenter.com/sap/opu/odata/sap/ZGWSAMPLE_SRV
In that I used ObjectLIstItem to get the list like below.
Following is the code to get the List like above.
var productList = new sap.m.GrowingList("list",{
threshold : 5
});
var objectTemplate = new sap.m.ObjectListItem({
title : "{ProductId}",
number : "{Price}",
numberUnit :"{CurrencyCode}",
press : [oController.productListTap, oController],
attributes : [new sap.m.ObjectAttribute({
text : "{Category}"
}), new sap.m.ObjectAttribute({
text : "{SupplierName}"
})],
firstStatus : new sap.m.ObjectStatus({
text : "{TypeCode}"
})
});
productList.bindItems("/ProductCollection", objectTemplate);
var page = new sap.m.Page("ProductPage", {
title : 'Product List',
content : [ productList ]
});
return page;
in ProductsController.js file
productListTap : function(evt){
alert("tap");
},
But here When I click on that list item I am not getting any alert message.
Please help me to solve this.
Thanks&Regards
Sridevi
Do you get any JavaScript errors in the console?
I'm not sure if this would solve your problem, but how I normally invoke a function in the controller from a UI5 control is via:
press : function(oEvent) {
oController.productListTap(oEvent);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I used tap event .That is also not working.
I used the below code.
var objectTemplate = new sap.m.ObjectListItem({
title : "{ProductId}",
number : "{Price}",
numberUnit :"{CurrencyCode}",
press : [oController.productListTap, oController],
attributes : [new sap.m.ObjectAttribute({
text : "{Category}"
}), new sap.m.ObjectAttribute({
text : "{SupplierName}"
})],
firstStatus : new sap.m.ObjectStatus({
text : "{TypeCode}"
})
});
Instead of this If I am using
var objectTemplate = new sap.m.StandardListItem({
title : "{Name}",
description : "{SupplierName}",
icon : "{ProductPicURL}",
iconInset : false,
iconDensityAware : false,
type : sap.m.ListType.Navigation,
tap : [ oController.productListTap, oController ]
});
Then it's working fine .But I am not getting above output when I am using StandardListItem.
Is there any other libraries to add when we are using ObjectListItem?
Thanks&Regards
Sridevi
Really strange... I honestly don't know why your code won't work actually.
I have created a little test HTML page, and here it perfectly works:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="UTF-8" />
<title></title>
<script
src="https://sapui5.netweaver.ondemand.com/sdk/resources/sap-ui-core.js"
type="text/javascript" id="sap-ui-bootstrap" data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal">
</script>
<script type="text/javascript">
jQuery.sap.require("sap.m.ObjectAttribute");
jQuery.sap.require("sap.m.MessageBox");
var list = new sap.m.List("singleSelectLeftList", {
headerText : "Items",
mode : "SingleSelectLeft"
});
function handleOnPress(oEvent) {
sap.m.MessageBox.show(
"onPress Event working as expected :-)",
sap.m.MessageBox.Icon.INFORMATION,
"Info");
}
var oliAttr = new Array();
oliAttr.push(new sap.m.ObjectAttribute( {
text : "Here's an attribute"
}));
oliAttr.push(new sap.m.ObjectAttribute( {
text : "Another attribute"
}));
var olItem = new sap.m.ObjectListItem( {
type : "Active",
intro : "Here's an intro",
title : "Testing sap.m.ObjectAttribute press event",
number : "123",
numberUnit : "Dollar",
attributes : oliAttr,
press : handleOnPress
});
list.addItem(olItem);
var app = new sap.m.App();
var page = new sap.m.Page( {
title : "sap.m.ObjectListItem press test"
});
app.setInitialPage(page.getId());
page.setEnableScrolling(true);
app.addPage(page);
page.addContent(list);
app.placeAt('body');
</script>
</head>
<body id="body" class="sapUiBody">
</body>
</html>
Message was edited by: Robin van het Hof added html formatting
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.