Skip to Content
-1

i got Cannot read property 'navTo' of undefined error . whats wrong with my code !!!

hello everyone,

I tried the following code but it's not working.

fragment

AddProductHierarchySet.fragment.xml

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:tnt="sap.tnt" xmlns:l="sap.ui.layout">

<Dialog title="PRODUCT HIERARCHY SET INFORMATION" contentHeight="70%" contentWidth="70%">

<content>

<mvc:XMLView viewName="Rmanagement.FRebateManagement.view.CollectionGroupDetails"/>

</content>

<endButton>

<Button text="Close" press="onCloseFragment"/>

</endButton>

</Dialog>

</core:FragmentDefinition>

manifest.json:

view

collectionGroupDetails.view.xml:

collectionGroupDetails.controller.js

view-code.jpg (24.8 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Jul 19 at 05:30 AM

    Hi Abhishek,

    I see no reason why you should not get the router object.

    Since I do not know the complete router configuration. Please also validate it is as specified in the documentation.

    The passed controller or view has to be created in the context of a UIComponent to return the router instance. Otherwise this function will return undefined. You may define the routerClass property in the config section of the routing to make the Component create your router extension.

    If this also doesn't work, try getting the router object from component itself.

    var oRouter = this.getOwnerComponent().getRouter();

    Thanks

    Prashil

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 19 at 03:25 AM

    Hi Abhishek,

    One point is the routing name "AddCollectionItem" has two arguments "groupId" and "itemId", while you are using only "groupId".

    As per the error, you are not getting the router object, please check if you have initialized router in your component.js using

    this.getRouter().initialize();

    Thanks

    Prashil

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 19 at 09:16 AM

    Hi Abhishek,

    Again, I tried similar code and for me it all worked well.

    Few things that I avoided that you can also check, you have multiple controlId's in your target. I am not sure about the intention behind it but usually, this should be the control id of your App control.

    Secondly, your have id "idApp" for your control and your target as well.

    If your view Tile is the rootView then it should have been added as the rootView inside "sap.ui5" and no in routing.

    Try fixing the above point and share the specific error your are facing.

    Thanks

    Prashil

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 20 at 06:15 AM

    Hi Abhishek,

    {
        "_version": "1.3.0",
        "sap.app": {
            "_version": "1.3.0",
            "id": "com.prashil.test",
            "type": "application",
            "resources": "resources.json",
            "i18n": "i18n/i18n.properties",
            "title": "{{appTitle}}",
            "description": "{{appDescription}}",
            "applicationVersion": {
                "version": "${project.version}"
            },
            "ach": "XX",
            "dataSources": {
                "mainService" : {
                    "uri": "/api/users",
                    "type" : "OData",
                    "settings": {
                        "odataVersion": "2.0"
                    }
                }
            },
            "sourceTemplate": {
                "id": "test",
                "version": "1.0.0"
            }
        },
        "sap.fiori": {
            "_version": "1.1.0",
            "registrationIds": [],
            "archeType": "transactional"
        },
        "sap.ui": {
            "_version": "1.3.0",
            "technology": "UI5",
            "icons": {
                "icon": "sap-icon://detail-view",
                "favIcon": "",
                "phone": "",
                "phone@2": "",
                "tablet": "",
                "tablet@2": ""
            },
            "deviceTypes": {
                "desktop": true,
                "tablet": true,
                "phone": true
            },
            "supportedThemes": [
                "sap_hcb",
                "sap_bluecrystal"
            ]
        },
        "sap.ui5": {
            "_version": "1.2.0",
            "rootView": {
                "viewName": "com.prashil.test.view.App",
                "type": "XML",
                "id": "app"
            },
            "dependencies": {
                "minUI5Version": "${sap.ui5.dist.version}",
                "libs": {
                    "sap.ui.core": {
                        "minVersion": "1.36.0"
                    },
                    "sap.m": {
                        "minVersion": "1.36.0"
                    }
                }
            },
            "contentDensities": {
                "compact": true,
                "cozy": true
            },
            "models": {
                "i18n": {
                    "type": "sap.ui.model.resource.ResourceModel",
                    "settings": {
                        "bundleName": "com.prashil.test.i18n.i18n"
                    }
                },
                "": {
                    "dataSource": "mainService",
                    "settings": {
                        "metadataUrlParams": {
                            "sap-documentation": "heading"
                        }
                    }
                }
            },
            "routing": {
                "config": {
                    "routerClass": "sap.m.routing.Router",
                    "viewType": "XML",
                    "viewPath": "com.prashil.test.view",
                    "controlId": "idAppControl",
                    "controlAggregation": "pages",
                    "clearControlAggregation" : false,
                    "bypassed": {
                        "target": [
                            "master",
                            "notFound"
                        ]
                    },
                    "async": true
                },
                "routes": [
                    {
                        "pattern": "",
                        "name": "Main",
                        "target": [
                            "main"
                        ]
                    },
                    {
                        "pattern": "newPage/type/:idType/value/:idValue",
                        "name": "newPage",
                        "target": "detail"
                    }
          ],
                "targets": {
                    "main": {
                        "viewName": "Main",
                        "viewLevel": 1,
                        "viewId": "master",
                        "controlAggregation": "pages"
                    },
                    "detail": {
                        "viewName": "Detail",
                        "viewLevel": 1,
                        "viewId": "detail",
                        "controlAggregation": "pages"
                    },
                    "sflight": {
                        "viewName": "SFlight",
                        "viewLevel": 1,
                        "viewId": "flight",
                        "controlAggregation": "pages"
                    }
                }
            }
        }
    }
    
    
    

    Thanks

    Prashil

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.