on 03-02-2015 6:32 PM
HI Guys,
I am trying to create a Left aligned vertical menu bar, similar to what we see on google playstore. So I am using an image + Object List Item control.
It looks well but the "press" event is not working on the ObjectListItem, though it works fine for the image. Here is what I am doing:
getMenuItems : function(){
var oImg1 = new sap.ui.commons.Image({
width : "65px",
height : "57px",
tooltip : "All Data Marts",
src : "WebContent/img/AllMarts.png",
press : function(oEvent){
alert("Hello"); ----------------------> This works
}
});
var oMenuItem1 = new sap.m.ObjectListItem({
title : "All Marts",
press : function(oEvent){
alert("Hello"); ------------------------> This does not
}
});
var oMenuLayout = new sap.ui.layout.HorizontalLayout();
oMenuLayout.addContent(oImg1);
oMenuLayout.addContent(oMenuItem1);
var oView = this.getView();
oView.oMenu.addContent(oMenuLayout);
}
Any thoughts how I can make it work? or any other ideas how I can create a menu like we see on playstore?
You should set the ObjectListItem's "type" property to "Active" (the default value is undefined or Inactive)
Furthermore, you should not mix sap.ui.commons and sap.m libraries; better use sap.m.Image instead
But to get back to your topic, why go through all the hassle and create a horizontal layout with separate image and list items? Why not simply add an icon to your ObjectListItem, and add it to a List instead of directly into a view?
(And if you don't need all the extra goodies an ObjectListItem offers, why not simply use a StandardListItem instead?)
For instance:
<List>
<StandardListItem
title="All Marts"
icon="WebContent/img/AllMarts.png"
press="handlePress" />
</List>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sap.m.ObjectListItem is for items aggregation of sap.m.List, no surprise press doesnt work
don't mix desktop and mobile API!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.