Sapui5路由器第二次无法在Master Detail App中使用

时间:2019-03-23 15:15:56

标签: sapui5

enter image description here大家好,

我在Master Detail Application中的路由中遇到问题。当我第一次点击主记录时。它重定向到详细信息视图。但是,如果我在“主视图”中单击另一条记录,则Router不会导航到“详细视图”。

有人可以帮我解决我的问题吗?

如果您看到上面的图片,当我在“第一条记录”上单击时,相应的详细信息将被加载到“详细信息视图”中。 如果我点击第二条记录(以红色突出显示),则不会触发“详细信息”页面。

下面是我正在尝试的代码...

Master.controller.js

onItemPress: function (oEvent) {
            var contextPath = oEvent.getParameter('listItem');
            var getPath = contextPath.getBindingContext("masterModel").getPath().split("/")[1];
            sap.ui.getCore().selRecordData = contextPath.getBindingContext("masterModel").getModel().getData()[getPath];
            this._router.navTo("detail");
        },

Detail Controller.js

onInit: function () {

            var oComponent = this.getOwnerComponent();
            this._router = oComponent.getRouter();
            this._router.getRoute("detail").attachPatternMatched(this._routePatternMatched, this);

        },

_routePatternMatched: function () {
            var detailModel = new sap.ui.model.json.JSONModel();
            detailModel.setData(sap.ui.getCore().selRecordData);
            this.getView().setModel(detailModel, "detailModel");
        }

manifest.json

"routing": {
            "config": {
                "routerClass": "sap.m.routing.Router",
                "viewType": "XML",
                "async": true,
                "viewPath": "sap.m.serviceRequestLast.view",
                "controlAggregation": "pages",
                "controlId": "idSplitApp",
                "clearControlAggregation": false
            },
            "routes": [{
                    "pattern": "",
                    "name": "master",
                    "target": [
                        "detail",
                        "master"
                    ]
                }, {
                    "pattern": "detail",
                    "name": "detail",
                    "target": [
                        "master",
                        "detail"
                    ]
                }

            ],
            "targets": {
                "master": {
                    "viewName": "Master",
                    "controlAggregation": "masterPages",
                    "viewLevel": 1
                },
                "detail": {
                    "viewType": "XML",
                    "transition": "slide",
                    "clearAggregation": true,
                    "viewName": "Detail",
                    "controlAggregation": "detailPages",
                    "viewLevel": 2
                }
            }
        }

有人可以帮我解决我的问题吗。

先谢谢您。

0 个答案:

没有答案