嗨,所有的专家,
我是sapui5中的一个新手,并且在list.view.js中有以下场景我已经定义了一个简单的表:
(function () {
"use strict";
sap.ui.jsview("fst.app.cList", {
getControllerName: function () {
return "fst.app.cList";
},
createContent: function (oController) {
//Back button
var oBackButton = new sap.m.Button({
text: "Back",
icon: "sap-icon://arrow-left",
press: oController.handleButtonPress
});
//New contract button
var oNewButton = new sap.m.Button({
text: "New",
icon: "sap-icon://add-document",
press: oController.addNewButtonPress
});
//Spacer
var oSpacer = sap.m.ToolbarSeparator();
//Table body
var oTable = sap.m.Table({
insert: true,
headerText: "List of Items",
headerDesign: sap.m.ListHeaderDesign.Standard,
mode: sap.m.ListMode.None,
includeItemInSelection: false
});
//Columns
var col01 = new sap.m.Column("col01", {
header: new sap.m.Label({
text: "Number"
})
});
oTable.addColumn(col01);
var col02 = new sap.m.Column("col02", {
header: new sap.m.Label({
text: "Product"
})
});
oTable.addColumn(col02);
var col03 = new sap.m.Column("col03", {
header: new sap.m.Label({
text: "Date"
})
});
oTable.addColumn(col03);
var colItems = new sap.m.ColumnListItem("colItems", {
type: "Active"
});
oTable.bindAggregation("items", "/value", colItems);
var txtNAME = new sap.m.Text("txtNAME", {
text: "{ProductID}"
});
colItems.addCell(txtNAME);
var txtNAME2 = new sap.m.Text("txtNAME2", {
text: "{ProductName}"
});
colItems.addCell(txtNAME2);
var txtNAME3 = new sap.m.Text("txtNAME3", {
text: "{UnitsInStock}"
});
colItems.addCell(txtNAME3);
var page = new sap.m.Page({
title: "Test",
enableScrolling: false,
content: [oBackButton, oSpacer, oNewButton, oTable]
});
return page;
}
});
})();
单击Button(oNewButton)时,将调用新视图(new.view.js) . 在这个视图中,我想要一个包含第一个视图中列的表单 .
谁能给我一些tipps如何以最好的方式实现这样的场景?
在此先感谢您的问候 . 丹尼斯
1 回答
从一个视图导航到另一个视图的最佳方法是使用路由器 . 查看此快速教程以了解其工作原理 . https://sapui5.hana.ondemand.com/#docs/guide/1b6dcd39a6a74f528b27ddb22f15af0d.html
要在导航中传递参数,我猜你有两个选择 . 1.-将它们作为路径模式中的参数传递 . 这些将出现在哈希路径中 . 检查此模式选项:https://sapui5.hana.ondemand.com/explored.html#/sample/sap.ui.core.sample.PatternMatching/preview
2.-如果必须传递许多字段,请在“组件”范围中创建模型 . 可以从所有视图访问Component范围 . 只需使用sap.ui.getCore() . setModel()并在目标视图中使用sap.ui.getCore() . getModel()然后将您从Core获得的Model设置为您拥有表单的容器 . 这里有一个片段:https://jsbin.com/tekisokevu/edit?html,output