on 2024 Oct 01 3:13 PM
Hello, I'm working on a TypeScript SAPUI5 app, in a table I need to route the user on the Object Page linked to the row.
Unfortunately, in the view controller when I want to get the Router to proceed with routing, i'm struck with an error: `Property 'getRouter' does not exist on type 'Component'.`
Here's the code :
onSessionPress(oEvent: any): void {
const oItem = oEvent.getSource();
const sSessionID = oItem.getBindingContext().getProperty("ID");
const oRouter = this.getOwnerComponent()?.getRouter();
oRouter.navTo("SessionObjectPage", {
ID: sSessionID
});
}
In the manifest.json, the routing is defined like this:
"routing": {
"routes": [
{
"name": "SessionsSessionsListPage",
"pattern": ":?query:",
"target": "SessionsSessionsListPage"
},
{
"name": "SessionsSessionObjectPage",
"pattern": "Sessions({SessionsKey}):?query:",
"target": "SessionsSessionObjectPage"
}
],
"targets": {
"SessionsSessionsListPage": {
"type": "Component",
"id": "SessionsSessionsListPage",
"name": "sap.fe.core.fpm",
"options": {
"settings": {
"viewName": "raceanalysis.ext.view.SessionsListPage",
"contextPath": "/Sessions",
"navigation": {
"Sessions": {
"detail": {
"route": "SessionsSessionObjectPage"
}
}
}
}
}
},
"SessionsSessionObjectPage": {
"type": "Component",
"id": "SessionsSessionObjectPage",
"name": "sap.fe.core.fpm",
"options": {
"settings": {
"viewName": "raceanalysis.ext.view.SessionObjectPage",
"contextPath": "/Sessions"
}
}
}
},
"config": {}
}
The only issue remotely similar I found is this: https://community.sap.com/t5/technology-q-a/navigation-problem/qaq-p/11609343 . But it's quite old and didn't found a clear answer.
Any help is appreciated !
Request clarification before answering.
I guess something is missing in your project. Have a look at the TS sample here: https://sap-samples.github.io/ui5-typescript-walkthrough/step-30/README.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
33 | |
21 | |
16 | |
8 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.