on 2018 Mar 12 10:20 AM
I am currently creating a Master-Detail UI5 app. I started my design process in Build, then generated a UI5 prototype. Once the prototype was agreed, I actually went back to the drawing board (from a coding perspective) and used one of the master-detail templates to generate a 'leaner' version than the generated one I got out of Build.
I am now in the process of connecting this 'leaner UI5 app with my real-world backend Gateway services.
I basically have a GW service to display open service orders (Order No, Order Description and Order creation date) in the master view list. This part works fine now. Upon selecting a item in this list, I am expecting Order Number and Text to be populated in the detail view. This is the step that's currently not working and I think there is something wrong in my routing/navigation and/or my OData model.
The error message I am getting is: error-chrome.jpeg
Below are my routing and target definitions from manifest.json. I have excluded any of the Error and NotFound views, by the way:
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "sap.ui.demo.masterdetail.view",
"controlId": "idAppControl",
"controlAggregation": "detailPages",
"bypassed": {
"target": [
"master",
"notFound"
]
},
"async": true
},
"routes": [
{
"pattern": "",
"name": "master",
"target": [
"detail",
"master"
]
},
{
"pattern": "ServiceOrderSet/{Aufnr}",
"name": "detail",
"target": [
"master",
"detail"
]
}
],
"targets": {
"master": {
"viewName": "Master",
"viewLevel": 1,
"viewId": "master",
"controlAggregation": "masterPages"
}
}
}
},
Service metadata. As you can see, I did not create any navigation, as I am not selecting any additional data, like service order operation data, for example:
<EntityType Name="ServiceOrders" sap:content-version="1">
<Key>
<PropertyRef Name="Aufnr"/>
</Key>
<Property Name="Aufnr" Type="Edm.String" Nullable="false" MaxLength="12" sap:unicode="false" sap:label="Order" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Ernam" Type="Edm.String" Nullable="false" MaxLength="12" sap:unicode="false" sap:label="Entered by" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Auart" Type="Edm.String" Nullable="false" MaxLength="4" sap:unicode="false" sap:label="Order Type" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Erdat" Type="Edm.DateTime" Nullable="false" Precision="7" sap:unicode="false" sap:label="Created on" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Ktext" Type="Edm.String" Nullable="false" MaxLength="20" sap:unicode="false" sap:label="Name" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
</EntityType>
<EntityContainer Name="ZGW_SERVICEORDER_SRV_03_Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx">
<EntitySet Name="ServiceOrders" EntityType="ZGW_SERVICEORDER_SRV_03.ServiceOrders" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:pageable="false" sap:content-version="1"/>
</EntityContainer>
In my Master.controller.js, I am getting the listItem parameter. I've checked this in debug and it appears to work.
onSelectionChange: function(oEvent) {
this._showDetail(oEvent.getParameter("listItem") || oEvent.getSource());
},
and finally the XML coding from my Master view. Also note the Aufnr and Ktext fields, which I would like to display here, but which are currently not showing:
<List id="list" items="{ path: '/ServiceOrderSet', sorter: { path: 'Aufnr', descending: false }, groupHeaderFactory: '.createGroupHeader' }"
busyIndicatorDelay="{masterView>/delay}" noDataText="{masterView>/noDataText}"
mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}" growing="true" growingScrollToLoad="true"
updateFinished="onUpdateFinished" selectionChange="onSelectionChange">
<infoToolbar>
<Toolbar active="true" id="filterBar" visible="{masterView>/isFilterBarVisible}" press="onOpenViewSettings">
<Title id="filterBarLabel" text="{masterView>/filterBarLabel}"/>
</Toolbar>
</infoToolbar>
<items>
<ObjectListItem type="{= ${device>/system/phone} ? 'Active' : 'Inactive'}" press="onSelectionChange" title="{Ktext}"
number="{path: 'Aufnr'}">
<attributes>
<ObjectAttribute
text="{path: 'Erdat', type: 'sap.ui.model.odata.type.DateTime', formatOptions: { style: 'short' }, constraints: { isDateOnly: true, displayFormat: 'Date' } }"/>
</attributes>
</ObjectListItem>
</items>
</List>
Update: below is the code of my _showDetail method:
_showDetail: function(oItem) {
var bReplace = !Device.system.phone;
this.getRouter().navTo("detail", {
objectId: oItem.getBindingContext().getProperty("Aufnr")
}, bReplace);
},
Update: below is the relevant part of my Deatil.xml view
...
<semantic:content>
<ObjectHeader id="objectHeader" title="{Ktext}" number="{Aufnr}"></ObjectHeader>
...
Does anybody have any pointers where I am going wrong here?
Thanks in advance,
Michael
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Hi Michael,
Could you please post the code of function _showDetail?
It seems you have not passed Aufnr as parameter when navigating to detail page.
Regards,
Tri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
Please try this:
Replace this line in _showDetail
objectId: oItem.getBindingContext().getProperty("Aufnr")
with
Aufnr: oItem.getBindingContext().getProperty("Aufnr")
since the pattern in manifest is using Aufnr
{"pattern": "ServiceOrderSet/{Aufnr}","name": "detail","target": ["master","detail"]}
Also, how do you implement onRouteMatch or bindView in Detail controller?
User | Count |
---|---|
84 | |
12 | |
9 | |
8 | |
8 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.