我无法在详细视图中查看作业的详细信息。以下是我的代码 - Component.js
metadata : {
rootView: "shell.app.poc.DWH.view.App",
routing : {
config : {
routerClass : "sap.m.routing.Router",
//targetClass : "sap.m.routing.Targets",
viewType : "XML",
viewPath : "shell.app.poc.DWH.view",
controlId : "app",
controlAggregation : "pages",
transition: "slide"
},
routes: [
{
"pattern": "",
"name": "home",
"target": "home"
},
{
"pattern": "jobdetails/{jobPath}",
"name": "jobdetails",
"target": "jobdetails"
}
],
targets : {
home: {
viewPath : "shell.app.poc.DWH.view",
viewName : "App",
// viewLevel : 0
},
jobdetails: {
viewPath : "shell.app.poc.DWH.view",
viewName: "Second",
//viewLevel : 1
}
}
}
},
我的模型是根据xsjs的JSON输出创建的,如下所示 -
var oModel = new JSONModel("http://<host><ins>/shell/app/poc/DWH/test.xsjs");
this.setModel(oModel);
每当我选择我的表的列表项时,我想导航到该项的详细信息页面。下面是每个列表项上onPress事件的主控制器的代码 -
onPress : function (oEvent) {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
var oItem, oCtx;
oItem = oEvent.getSource();
oCtx = oItem.getBindingContext();
var object = oCtx.getObject();
//var path = this.getView().getElementBinding('records').sPath.substring(1)
//var context = this.getView().getElementBinding('records').oContext;
oRouter.navTo("jobdetails", {
jobPath: oCtx.getProperty("bodsjobconcntrlid")
//jobPath: oItem.getBindingContext('/records').getPath().substr(1)
});
console.log('oEvent.getSource: ' + oEvent.getSource());
// console.log('path: ' + this.getView().getBindingContext().getPath());
oCtx = oItem.getBindingContext();
console.log('oEvent.getsource.getBindingContext: ' + oEvent.getSource().getBindingContext());
console.log('oCtx.getProperty: ' + oCtx.getProperty("bodsjobconcntrlid"));
console.log('object: ' + oCtx.getObject());
//console.log('context: ' + context);
}
这是我的详细信息控制器的代码 -
onInit: function () {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.getRoute("home").attachMatched(this._onObjectMatched, this);
},
_onObjectMatched: function (oEvent) {
var oArgs, oView;
oArgs = oEvent.getParameter("arguments");
oView = this.getView();
oView.bindElement({
path : "/records(" + oArgs.bodsjobconcntrlid + ")"
});
},
这是我的详细信息视图
我只是得到了标签的作业名,但实际上没有任何价值...... 这是我桌子的绑定 -
items="{path: '/records'}"
请帮忙
答案 0 :(得分:0)
将您的视图绑定到此详细记录
oView.bindElement({
path : "/records(" + oArgs.bodsjobconcntrlid + ")"
});
如果您在该详细记录下有记录&#34; /记录(&#34; + oArgs.bodsjobconcntrlid +&#34;)&#34;, 你应该使用
items="{path: 'records'}"