本文介绍了SAPUI5 将单个主节点路由到多个细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从主视图导航到多个详细视图.但是我不知道在component.js中怎么做,所有的示例都是简单的细节视图.我可以导航到所有视图,但无法从 odata 获取绑定,只有路由工作中的最后一个详细信息视图正确.

I'm Trying navigate from Master view to Multiple detail views.But I don't know how do it in component.js, all the samples are simple detail views. I can Navigate to all views but I can't get the binding from odata, only the last detail view in routing work's correctly.

component.js 代码:

component.js code:

    routing : {
        config : {
            routerClass : ZPPS.MyRouter,
            viewType : "XML",
            viewPath : "ZPPS.view",
            targetAggregation : "detailPages",
            clearTarget : false
        },
        routes : [
            {
                pattern : "",
                name : "main",
                view : "Master",
                targetAggregation : "masterPages",
                targetControl : "idAppControl",
                subroutes : [
                    {
                        pattern : "{entity}/:tab:",
                        name : "detail",
                        view : "Detail"
                    }
                ]
            },
            {
                pattern : "",
                name : "main",
                view : "Master",
                targetAggregation : "masterPages",
                targetControl : "idAppControl",
                subroutes : [
                    {
                        pattern : "{entity}/:tab:",
                        name : "placeDetail",
                        view : "PlaceDetail"
                    }
                ]
            },
            {
                pattern : "",
                name : "main",
                view : "Master",
                targetAggregation : "masterPages",
                targetControl : "idAppControl",
                subroutes : [
                    {
                        pattern : "{entity}/:tab:",
                        name : "vehicleDetail",
                        view : "VehicleDetail"
                    }
                ]
            },
            {
                name : "catchallMaster",
                view : "Master",
                targetAggregation : "masterPages",
                targetControl : "idAppControl",
                subroutes : [
                    {
                        pattern : ":all*:",
                        name : "catchallDetail",
                        view : "NotFound",
                        transition : "show"
                    }
                ]
            }
        ]
    }

推荐答案

你必须使用十字路口的贪婪功能.路由器基本上是一个名为 crossroads 的 thridparty-lib,封装在 SAPUI5-Class 中.

You have to use the greedy functionality of crossroads.The router is basically a thridparty-lib called crossroads wrapped in a SAPUI5-Class.

默认实现禁用了贪婪选项.这意味着路由器会通过您的路线并采用匹配的第一条路线......就是这样.

the default implementation has the greedy option disabled. That means the router goes through your routes and takes the first route that matched... and thats it.

使用 greedy 选项告诉路由器搜索所有匹配的模式,而不仅仅是第一个.

with greedy option you tell the router to search for all matching pattern and not only the first.

以这个路由器为例如何启用贪婪选项:http://ui5.de/core/Router.js

take this router as example how to enable greedy option:http://ui5.de/core/Router.js

这篇关于SAPUI5 将单个主节点路由到多个细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 04:10