tablesa.view.js:
sap.ui.jsview("tablesa.tablesa", {
getControllerName : function() {
return "tablesa.tablesa";
},
createContent : function(oController) {
var data = [ {fname : "indrajith" , lname : "SCN"},
{fname : "fred" , lname : "SCN1"},
{fname : "den" , lname : "SCN2"},
{fname : "foo" , lname : "SCN3"},
{fname : "red" , lname : "SCN4"},
]
var oModel = sap.ui.model.json.JSONModel();
oModel.setData(data)
var oTable = new sap.m.Table({
mode: sap.m.ListMode.SingleSelectMaster,
columns: [
new sap.m.Column({
header : new sap.m.Label({
text : "First Name"
})
}),
new sap.m.Column({
header : new sap.m.Label({
text : "Last Name"
})
})
],
});
oTable.setModel(oModel)
oTable.bindAggregation("items", {
path: "/",
template: new sap.m.ColumnListItem({
cells: [
(new sap.m.Text({ text: "{fname}" }).attachBrowserEvent("click",function(e){
var pid = e.target.id
/* alert(pid);*/
alert(sap.ui.getCore().byId(pid).getText())
})),
(new sap.m.Text({ text: "{lname}" }).attachBrowserEvent("click",function(e){
var pid = e.target.id
/*alert(pid);*/
alert(sap.ui.getCore().byId(pid).getText())
})),
]
})
})
return new sap.m.Page({
title: "Title",
content: [
oTable
]
});
}
});
output:
sap.ui.jsview("tablesa.tablesa", {
getControllerName : function() {
return "tablesa.tablesa";
},
createContent : function(oController) {
var data = [ {fname : "indrajith" , lname : "SCN"},
{fname : "fred" , lname : "SCN1"},
{fname : "den" , lname : "SCN2"},
{fname : "foo" , lname : "SCN3"},
{fname : "red" , lname : "SCN4"},
]
var oModel = sap.ui.model.json.JSONModel();
oModel.setData(data)
var oTable = new sap.m.Table({
mode: sap.m.ListMode.SingleSelectMaster,
columns: [
new sap.m.Column({
header : new sap.m.Label({
text : "First Name"
})
}),
new sap.m.Column({
header : new sap.m.Label({
text : "Last Name"
})
})
],
});
oTable.setModel(oModel)
oTable.bindAggregation("items", {
path: "/",
template: new sap.m.ColumnListItem({
cells: [
(new sap.m.Text({ text: "{fname}" }).attachBrowserEvent("click",function(e){
var pid = e.target.id
/* alert(pid);*/
alert(sap.ui.getCore().byId(pid).getText())
})),
(new sap.m.Text({ text: "{lname}" }).attachBrowserEvent("click",function(e){
var pid = e.target.id
/*alert(pid);*/
alert(sap.ui.getCore().byId(pid).getText())
})),
]
})
})
return new sap.m.Page({
title: "Title",
content: [
oTable
]
});
}
});
output:
No comments:
Post a Comment