I have problem with creating grand child routing in durandal. I have attached my code please check.

9 views
Skip to first unread message

pravin murumkar

unread,
Sep 26, 2016, 2:21:49 AM9/26/16
to DurandalJS
second level routing work properly but  grand child routing not work. see attached screen shots

1) First level routing :  code in shell.js 

define(['plugins/router', 'durandal/app'], function (router, app) {
    return {
        router: router,
        search: function() {
            //It's really easy to show a message box.
            //You can add custom options too. Also, it returns a promise for the user's response.
            app.showMessage('Search not yet implemented...');
        },
        activate: function () {
            router.map([               
                { route: ['', 'viewmodels/Planning*details'], title: 'PRODUCT SELECTION', moduleId: 'viewmodels/Planning/productSelection', nav: true, hash: '#viewmodels/Planning' },
                { route: 'priceStrategy', title: 'PRICE STRATEGY', moduleId: 'viewmodels/Planning/priceStrategy', nav: true },
                { route: 'approvals', title: 'APPROVALS', moduleId: 'viewmodels/Planning/Approvals', nav: true },
                { route: ['', 'viewmodels/Execution*details'], title: 'Approvals', moduleId: 'viewmodels/Execution/approvals', nav: true, hash: '#viewmodels/Execution' },

            ]).buildNavigationModel();        
            return router.activate();
        }
    };
});

2)second level routing : code in ProductSelection.js

define(['plugins/router', 'durandal/system', 'durandal/app', './simpleGrid', 'knockout'], function (router,system, app, SimpleGrid, ko) {

    //var ko = require('knockout');
    var childRouter = router.createChildRouter()
           .makeRelative({
               moduleId: 'viewmodels/Planning',
               fromParent: true
           }).map([
               { route: ['', 'Composite_Score*details'], moduleId: 'Composite_Score/CScore', title: 'Composite Score', type: 'intro', nav: true, hash: '#viewmodels/Planning/Composite_Score' },
               { route: 'PricingPlaning', moduleId: 'Profile/PricingPlaning', title: 'Profile', type: 'intro', nav: true },
               { route: 'Price_Change', moduleId: 'Price_Point/Price_Change', title: 'Price Point', type: 'intro', nav: true },
               { route: 'Productlist', moduleId: 'Financials/Productlist', title: 'Financials', type: 'intro', nav: true }        
              ]).buildNavigationModel();
    return {
        router: childRouter,
        introSamples: ko.computed(function () {
            return ko.utils.arrayFilter(childRouter.navigationModel(), function (route) {
                return route.type == 'intro';
            });
        })        
    };
});

3) Grand chind routing: code in CScore.js 
define(['plugins/router', 'durandal/system', 'durandal/app', 'knockout'], function (router, system, app,ko) {

    //var ko = require('knockout');
    var childRouter = router.createChildRouter()
           .makeRelative({
               moduleId: 'viewmodels/Planning/Composite_Score',
               fromParent: true
           }).map([
               { route: 'Composite_Score/compositeScore', moduleId: 'Composite_Score/CS/compositeScore', title: 'Composite Score', type: 'intro', nav: true },
               { route: 'Composite_Score/Productlist1', moduleId: 'Composite_Score/CS1/Productlist1', title: 'Profile1', type: 'intro', nav: true },
               ]).buildNavigationModel();
    return {
        router: childRouter,
        introSamples: ko.computed(function () {
            return ko.utils.arrayFilter(childRouter.navigationModel(), function (route) {
                return route.type == 'intro';
            });
        })
    };
});
Reply all
Reply to author
Forward
0 new messages