I have created a table is SAPUI5,now i want to make a cell clickable.This is my table
var oTable = new sap.ui.table.Table({
visibleRowCount: 4,
firstVisibleRow: 3,
editable: false,
rowHeight:40,
align:"center",
width:"100%",
rowBorderStyle:"none",
styleExpression :"color:white;",
selectionMode: sap.ui.table.SelectionMode.Single,
});
//Define the columns and the control templates to be used
var oColumn = new sap.ui.table.Column({
label: new sap.uimons.Label({text: "RequestID"}),
styleExpression :"'padding:10px 10px 10px 10px;'",
template: new sap.uimons.TextView().bindProperty("text","RequestID"),
sortProperty: "RequetID",
filterProperty: "RequetID",
width: "75px",
hAlign: "Center"
});
oTable.addColumn(oColumn);
oTable.addColumn(new sap.ui.table.Column({
label: new sap.uimons.Label({text: "First Name"}),
template: new sap.uimons.TextField().bindProperty("value","name"),
sortProperty: "name",
filterProperty: "name",
width: "75px",
hAlign: "Center"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.uimons.Label({text: "Subject"}),
template: new sap.uimons.TextField().bindProperty("value","Summary"),
sortProperty: "Summary",
filterProperty: "Summary",
width: "100px",
hAlign: "Center"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.uimons.Label({text: "Attachment"}),
template: new sap.uimons.Image().bindProperty("src", "src"),
sortProperty: "src",
filterProperty: "src",
width: "75px",
hAlign: "Center",
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.uimons.Label({text: "Create Date"}),
template: new sap.uimons.TextField().bindProperty("value", "CreateDate"),
sortProperty: "CreateDate",
filterProperty: "CreateDate",
width: "75px",
hAlign: "Center",
}));
var oColumn=new sap.ui.table.Column({
label: new sap.uimons.Label({text: "Info"}),
template: new sap.uimons.Image().bindProperty("src", "src1"),
sortProperty: "src1",
filterProperty: "src1",
width: "75px",
hAlign: "Center",
addStyleClass: "infoimg",
});
oColumn.attachEvent("click",function cl(){alert("hi");});
oTable.addColumn(oColumn);
oTable.addColumn(new sap.ui.table.Column({
label: new sap.uimons.Label({text: "Status"}),
template: new sap.uimons.TextField().bindProperty("value", "Status"),
sortProperty: "Status",
filterProperty: "Status",
width: "75px",
hAlign: "Center"
}));
Here is the array which i have binded with the table
var aData = [
{RequestID: 1, name: "Al", Summary: "False Trading", src: "images/docc.png", CreateDate: "21/08/2014", src1: "images/icn_info_unselected.png", Status: "Open"},
{RequestID: 27, name: "Andy", Summary: "Invalid Transaction", src: "images/pdff.png", CreateDate: "23/08/2014", src1: "images/icn_info_unselected.png", Status: "Open"},
{RequestID: 39, name: "Anita", Summary: "False Trading", src: "images/docc.png", CreateDate: "24/08/2014", src1: "images/icn_info_unselected.png", Status: "Open"},
{RequestID: 67, name: "Doris", Summary: "Invalid Transaction", src: "images/pdff.png", CreateDate: "25/08/2014", src1: "images/icn_info_unselected.png", Status: "Close"}
];
Here I want to make image in the info column clickable.i have tried using jquery and javascript.
jQUERY:-
$('#__image2-col5-row0').click(function()
{
alert("hi");
});
JAVASCRIPT:-
var a=document.getElementById('__image2-col5-row0');
alert(a);
a.attachEvent('click', function() {
alert('Hello world');
});
Both These methods are not working.Javascript returnts the value of "a" as null.Does SAPUI5 has a inbuilt way of adding the event handler like click on a table cell
Please Help
I have created a table is SAPUI5,now i want to make a cell clickable.This is my table
var oTable = new sap.ui.table.Table({
visibleRowCount: 4,
firstVisibleRow: 3,
editable: false,
rowHeight:40,
align:"center",
width:"100%",
rowBorderStyle:"none",
styleExpression :"color:white;",
selectionMode: sap.ui.table.SelectionMode.Single,
});
//Define the columns and the control templates to be used
var oColumn = new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "RequestID"}),
styleExpression :"'padding:10px 10px 10px 10px;'",
template: new sap.ui.mons.TextView().bindProperty("text","RequestID"),
sortProperty: "RequetID",
filterProperty: "RequetID",
width: "75px",
hAlign: "Center"
});
oTable.addColumn(oColumn);
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "First Name"}),
template: new sap.ui.mons.TextField().bindProperty("value","name"),
sortProperty: "name",
filterProperty: "name",
width: "75px",
hAlign: "Center"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "Subject"}),
template: new sap.ui.mons.TextField().bindProperty("value","Summary"),
sortProperty: "Summary",
filterProperty: "Summary",
width: "100px",
hAlign: "Center"
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "Attachment"}),
template: new sap.ui.mons.Image().bindProperty("src", "src"),
sortProperty: "src",
filterProperty: "src",
width: "75px",
hAlign: "Center",
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "Create Date"}),
template: new sap.ui.mons.TextField().bindProperty("value", "CreateDate"),
sortProperty: "CreateDate",
filterProperty: "CreateDate",
width: "75px",
hAlign: "Center",
}));
var oColumn=new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "Info"}),
template: new sap.ui.mons.Image().bindProperty("src", "src1"),
sortProperty: "src1",
filterProperty: "src1",
width: "75px",
hAlign: "Center",
addStyleClass: "infoimg",
});
oColumn.attachEvent("click",function cl(){alert("hi");});
oTable.addColumn(oColumn);
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "Status"}),
template: new sap.ui.mons.TextField().bindProperty("value", "Status"),
sortProperty: "Status",
filterProperty: "Status",
width: "75px",
hAlign: "Center"
}));
Here is the array which i have binded with the table
var aData = [
{RequestID: 1, name: "Al", Summary: "False Trading", src: "images/docc.png", CreateDate: "21/08/2014", src1: "images/icn_info_unselected.png", Status: "Open"},
{RequestID: 27, name: "Andy", Summary: "Invalid Transaction", src: "images/pdff.png", CreateDate: "23/08/2014", src1: "images/icn_info_unselected.png", Status: "Open"},
{RequestID: 39, name: "Anita", Summary: "False Trading", src: "images/docc.png", CreateDate: "24/08/2014", src1: "images/icn_info_unselected.png", Status: "Open"},
{RequestID: 67, name: "Doris", Summary: "Invalid Transaction", src: "images/pdff.png", CreateDate: "25/08/2014", src1: "images/icn_info_unselected.png", Status: "Close"}
];
Here I want to make image in the info column clickable.i have tried using jquery and javascript.
jQUERY:-
$('#__image2-col5-row0').click(function()
{
alert("hi");
});
JAVASCRIPT:-
var a=document.getElementById('__image2-col5-row0');
alert(a);
a.attachEvent('click', function() {
alert('Hello world');
});
Both These methods are not working.Javascript returnts the value of "a" as null.Does SAPUI5 has a inbuilt way of adding the event handler like click on a table cell
Please Help
Share Improve this question edited Nov 5, 2014 at 11:08 user3714734 asked Nov 5, 2014 at 11:02 user3714734user3714734 31 silver badge3 bronze badges1 Answer
Reset to default 3sap.ui.mons.Image
has a press
event.
var oColumn=new sap.ui.table.Column({
label: new sap.ui.mons.Label({text: "Info"}),
template: new sap.ui.mons.Image({
press:function(){alert("hi");}}
).bindProperty("src", "src1"),
sortProperty: "src1",
filterProperty: "src1",
width: "75px",
hAlign: "Center",
addStyleClass: "infoimg",
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745092066a4610750.html
评论列表(0条)