SAPUI5绑定问题:json文件中维护的列表项链接不起作用
SAPUI5 binding issue: list item links maintained in json file do not work
以下情况。我在xml视图中定义了一个表(文本内容位于json文件中)。对于每个列表项,都定义了一个按下事件,这样点击该项就可以转到另一个页面或打开一个文件。所有内容都已正确显示,但单击事件不起作用。请提供反馈。谢谢
<VBox
id="idVBox">
<items>
<Table id="idProductsTable" inset="false"
items="{
path: '/ProductCollection',
sorter: {
path: 'Name'
}
}">
<columns>
<Column>
</Column>
</columns>
<items>
<ColumnListItem type="Navigation" press="{target}" >
<cells >
<ObjectIdentifier
title="{Name}"
class="sapMTableContentMargin" />
</cells>
</ColumnListItem>
</items>
</Table>
</items>
json看起来像这样:
{"ProductCollection": [
{
"Name" : "blabla1",
"target" : "ee1" },
{
"Name" : "blabla2",
"target" : "ee2"
}, ....
在js控制器中,我定义了如下目标:
onInit: function() {
this.bus = sap.ui.getCore().getEventBus();
// set explored app's demo model on this sample
var oModel = new sap.ui.model.json.JSONModel("model/scopelist.json");
this.getView().setModel(oModel);
// Append demo table into VBox, making a minor modification
// to the first column so that the Category information is shown
var oTable = this.getView().byId("idProductsTable");
var oBindingInfo = oTable.getBindingInfo("items");
oBindingInfo.template.removeCell(0);
oBindingInfo.template.insertCell(new sap.m.ObjectIdentifier({
title: "{Name}",
text: "{Category}"
}));
oTable.bindItems(oBindingInfo);
this.getView().byId("idVBox").addItem(oTable);
}, ....
ee1: function() {
window.open("something1.pdf", "_blank");
},
ee2: function() {
window.open("./docu/something2.pdf", "_blank");
}, ...
我认为press
事件不支持数据绑定,即允许动态函数命名。
推荐的方法是只引用一个命名的事件处理程序:
press="handlePress"
并在控制器中创建事件处理程序:
handlePress: function(oEvent) {
// get the current object from your table array
var obj = oEvent.getSource().getBindingContext().getObject();
if (obj.target === "ee1") {
//do something
}
else if (obj.target === "ee2") {
//do something else
}
}
相关文章:
- 要求输入在数据列表中
- 从javascript创建一个列表
- 如何使用jQuery选择下拉列表的值
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 将jsp文件下拉列表中的选定项分配给一个java变量(比如String selection)
- Javascript按钮下拉列表
- 如何使用json将对象列表从java转换为javascript
- 区分JSON中的矩阵和列表列表
- jQuery表单添加不适用于下拉列表
- 用每小时的差值填充数组/列表-从下拉列表中给定两个时间值
- 接受不在列表中的值-引导组合框
- 禁用jQuery中的下拉列表
- 从HTTPGET返回一个自定义对象列表,以便在Angular 2应用程序中使用
- 如何在javascript中迭代数字列表
- 如何在按钮中显示下拉列表中选定的元素
- 为什么HTML5拖放的目标是孩子?(可排序列表)
- 鼠标悬停事件影响列表中所有行中的按钮,而不仅仅是特定按钮
- 使用图像数组列表的simplegallary.js显示适合桌面屏幕的图像
- SAPUI5绑定问题:json文件中维护的列表项链接不起作用
- JQuery列表项链接在拖放时丢失