Sapui5栏链接 [英] Sapui5 column of links
本文介绍了Sapui5栏链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一列链接。我希望每个链接在单击时在弹出框中显示不同的信息。我如何才能完成此任务?
以下是我创建的列:
oControl = new sap.m.Link({ text: "{userEmails}" });
oTable.addColumn(new sap.ui.table.Column("userEmails", {
label: new sap.m.Label({ text: "User Emails" }),
template: oControl,
sortProperty: "userEmails",
filterProperty: "userEmails"
}));
我希望根据链接被单击的行来显示用户电子邮件。
编辑:以下是我尝试的内容:
onLinkPressed: function (oEvent) {
var obj = oEvent.getSource().getBindingContext().getObject();
var email = obj.email;
}
电子邮件是另一列。 当我单击该链接时,没有任何反应。
EDIT2:我也试过这个:
oControl = new sap.m.Link({text: "{userEmails}", press: function() {openDialog();}}); // edited from the first line of code I posted
function openDialog() {
var oDialog1 = new sap.ui.commons.Dialog();
oDialog1.setTitle("My first Dialog");
var oText = new sap.ui.commons.TextView({ text: "example@email.com" });
oDialog1.addContent(oText);
oDialog1.addButton(new sap.ui.commons.Button({ text: "OK", press: function () { oDialog1.close(); } }));
oDialog1.open();
}
这将创建一个打开的对话框,但是每个链接提供相同的信息,我希望每个链接提供不同的信息。
推荐答案
我终于想明白了!以下是我的工作代码:
oControl = new sap.m.Link({ text: "{userEmails}", press: function (oEvent) { openDialog(oEvent);}});
oTable.addColumn(new sap.ui.table.Column("userEmails", {
label: new sap.m.Label({ text: "User Emails" }),
template: oControl,
sortProperty: "userEmails",
filterProperty: "userEmails",
}));
function openDialog(oEvent) {
var oDialog1 = new sap.ui.commons.Dialog();
oDialog1.setTitle("Emails");
var obj = oEvent.getSource().getBindingContext().getObject();
var email = obj.email;
var oText = new sap.ui.commons.TextView({ text: email });
oDialog1.addContent(oText);
oDialog1.addButton(new sap.ui.commons.Button({ text: "OK", press: function () { oDialog1.close(); } }));
oDialog1.open();
}
这篇关于Sapui5栏链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文