on 08-13-2015 5:54 PM
Finally got the answer
productListTap : function(oEvent) {
var listdata = oEvent.mParameters.listItem.mProperties;
console.log(listdata);
var intro = listdata.intro;
var number = listdata.number;
var title = listdata.title;
var Array = {};
Array.intro = intro;
Array.number = number;
Array.title = title;
},
thanks for every one who helped me in getting different ideas for solving it.Now i am able to get the selected list item properties into an array.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suneel,
Check this example:-
In Controller.js-
onInit: function() {
var oData = {
eventlistp:[
{
ADV_CAL_ID : "Test",
CalPlace : "Conferences",
DR_NAME : "Test",
CalPlndDat : "asasas",
PsrHq : "sasa"
},
{
ADV_CAL_ID : "Test",
CalPlace : "Conferences",
DR_NAME : "Test",
CalPlndDat : "asasas",
PsrHq : "sasa"
}
]
};
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
this.getView().setModel(oModel,"ReadActivites");
var oFormModel = new sap.ui.model.json.JSONModel();
oFormModel.setData(undefined);
this.getView().setModel(oFormModel,"ReadFormActivites");
},
productListTap: function(oEvent){
var bindingcontext = oEvent.getParameters("LISTITEM").listItem.getBindingContextPath("ReadActivites");
var oData = this.getView().getModel("ReadActivites").getData().eventlistp[bindingcontext.split("/")[2]];
this.getView().getModel("ReadFormActivites").setData(oData);
}
In View.js
createContent : function(oController) {
var oItemtemplate = new sap.m.ObjectListItem("LISTITEM",{
title:"{ReadActivites>ADV_CAL_ID}",
text : "{ReadActivites>CalPlace}",
number :"{ReadActivites>DR_NAME}",
numberUnit : "{ReadActivites>CalPlndDat}",
intro : "{ReadActivites>PsrHq}",
type : sap.m.ListType.Active,
markFavorite : true,
markFlagged : true,
});
var oList = new sap.m.List({mode:"SingleSelectMaster", id:"listId",
items:{path:"ReadActivites>/eventlistp", template:oItemtemplate},
itemPress : function(oEvent){
oController.productListTap(oEvent);
},
});
var oSimpleForm = sap.ui.layout.form.SimpleForm({
content: [
new sap.ui.commons.TextField({placeholder: "ADV_CAL_ID", value: "{ReadFormActivites>/ADV_CAL_ID}"}),
new sap.ui.commons.TextField({placeholder: "CalPlace", value: "{ReadFormActivites>/CalPlace}"}),
new sap.ui.commons.TextField({placeholder: "DR_NAME", value: "{ReadFormActivites>/DR_NAME}"}),
new sap.ui.commons.TextField({placeholder: "CalPlndDat", value: "{ReadFormActivites>/CalPlndDat}"}),
new sap.ui.commons.TextField({placeholder: "PsrHq", value: "{ReadFormActivites>/PsrHq}"})
]
});
oSimpleForm.setModel(oController.getView().getModel("ReadFormActivites"));
return new sap.m.Page({
title: "List Detail Example",
content: [oList,oSimpleForm]
});
}
Regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i want syntax for that how to get those properties from mProperties under oEvent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
console.log(oEvent.mParameters.listItem.mProperties.intro)
But i would not suggest you to take this way to access the property. This is not the right way
Did yu try this.?
productListTap : function(oEvent) {
var data = {};
var bindingcontext = oEvent.getParameter("listItem").getBindingContext("ReadActivites");
console.log(bindingcontext)
var path = bindingcontext .getPath()
console.log(path)
}
what error do you get?
If you want any property, it would be as simple as calling getProperty function on bindingcontext
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you do console.log(bindingcontext) what are you getting ?
Have a look at this example
JS Bin - Collaborative JavaScript Debugging
Credits to santosh..Found this example from
sorry my bad..it should be
productListTap : function(oEvent) {
var data = {};
var bindingcontext = oEvent.getParameter("listItem").getBindingContext("ReadActivites");
var path = bindingcontext .getPath()
console.log(path)
}
Message was edited by: indrajith patel
This code might be helpful.
var oList = this.getView().byId("listId");
var contexts = oTable.getSelectedContexts();
if(contexts.length == 0 ){
alert("Please select a row.");
}else {
var items = contexts.map(function(c) {
return c.getObject();
});
var oId = this.getView().byId("form1InputId");
oId.setValue(items[0].Field1);
var oId = this.getView().byId("form2InputId "); oId.setValue(items[0].Field2);
var oId = this.getView().byId("form3InputId ");
oId.setValue(items[0].Field3);
var oId = this.getView().byId("form4InputId ");
oId.setValue(items[0].Field4);
var oId = this.getView().byId("form5InputId ");
oId.setValue(items[0].Field5);
var oId = this.getView().byId("form6InputId ");
oId.setValue(items[0].Field6);
}
In view.js file
------------------
var oItemtemplate = new sap.m.ObjectListItem("LISTITEM",{
title:"{ReadActivites>ADV_CAL_ID}",
text : "{ReadActivites>CalPlace}",
number :"{ReadActivites>DR_NAME}",
numberUnit : "{ReadActivites>CalPlndDat}",
intro : "{ReadActivites>PsrHq}",
type : sap.m.ListType.Active,
markFavorite : true,
markFlagged : true,
});
var oList = new sap.m.List({mode:"SingleSelectMaster", id:"listId",
items:{path:"ReadActivites>/eventlistp", template:oItemtemplate},
itemPress : function(oEvent){
oController.productListTap(oEvent); },
});
in controller.js
--------------------
productListTap : function(oEvent) {
var data = {};
data.context = oEvent.getSource().getBindingContext("ReadActivites");
var selectedIndex = data.context.sPath.split("/")[2];
console.log(data.context);
But it is giving sPath is not a valid property like that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suneel,
Use selectionChange event of sap.m.List and try this -
oEvent.getSource().getBinding("items").getContexts()[oEvent.getSource().indexOfItem(oEvent.getParameter("listItem"))].sPath
Check the working sample - JS Bin - Collaborative JavaScript Debugging
Regards,
Sai Vellanki.
Hi Suneel,
Please provide your code which you have tried.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
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.