我观看了一些关于导航+在视图之间传递数据的教程,但它在我的情况下不起作用.我的目标是实现以下目标:
导航工作完美,详细信息页面显示,但数据绑定似乎不起作用(没有数据显示)我的想法是将JSON字符串传递给详细信息页面.我怎样才能做到这一点?还是有更优雅的方式?
这是迄今为止的代码:
MainView控制器
sap.ui.controller("my.zodb_demo.MainView", {
onInit: function() {
var oModel = new sap.ui.model.json.JSONModel("zodb_demo/model/products.json");
var mainTable = this.getView().byId("productsTable");
this.getView().setModel(oModel);
mainTable.setModel(oModel);
mainTable.bindItems("/ProductCollection", new sap.m.ColumnListItem({
cells: [new sap.m.Text({
text: "{Name}"
}), new sap.m.Text({
text: "{SupplierName}"
}), new sap.m.Text({
text: "{Price}"
})]
}));
},
onDetailsPressed: function(oEvent) {
var oTable = this.getView().byId("productsTable");
var contexts = oTable.getSelectedContexts();
var items = contexts.map(function(c) {
return c.getObject();
});
var app = sap.ui.getCore().byId("mainApp");
var page = app.getPage("DetailsForm");
//Just to check if the selected JSON String is correct …
Run Code Online (Sandbox Code Playgroud) 我想将一个JSON对象从一个控制器传递给另一个控制器.我怎么做?
或者我可以将oModel传递给另一个视图吗?如果是这样,我该怎么做?
谢谢
sapui5 ×2