on 01-10-2024 9:30 AM
Hi folks
I'm using fiori freestyle development for a requirment, using cds view as data source, I have created a list page and on clicking any item it will navigate to the deatil page but the data is not displaying,
Please find the controller and view for the details/object page , is anything im missing here
sap.ui.define([
'sap/ui/core/mvc/Controller',
'sap/ui/model/odata/v2/ODataModel',
'sap/ui/model/Filter',
'sap/ui/core/util/MockServer',
'sap/m/MessageToast',
'sap/ui/core/routing/History',
], function (Controller, ODataModel, Filter) {
"use strict";
return Controller.extend("myapp.controller.DisplayRequest", {
onInit: function () {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.getRoute("DisplayRequest").attachMatched(this._onRouteMatched, this);
},
_onRouteMatched: function (oEvent) {
var oArgs = oEvent.getParameter("arguments");
var reqid = oArgs.Reqid;
this._fetchData(reqid);
}
_fetchData: function (reqid) {
var oData = this.getView().getModel().read("/myCDSView", {
filters: [new sap.ui.model.Filter("reqid", sap.ui.model.FilterOperator.EQ, reqid)],
success: function (oData) {
var oModel = new sap.ui.model.json.JSONModel(oData);
this.getView().setModel(oModel, "data");
}.bind(this),
error: function (oError) {
// Handle error
}
});
}
});
});
<mvc:View<br>controllerName="myapp.controller.DisplayRequest" height="100%"
xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m"
xmlns:core="sap.ui.core" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
xmlns:smartTable="sap.ui.comp.smarttable" xmlns:uxap="sap.uxap" xmlns:form="sap.ui.comp.smartform"
xmlns:smart="sap.ui.comp.smartfield">
>
<uxap:ObjectPageLayout>
<uxap:headerTitle>
</uxap:headerTitle>
<uxap:sections>
<uxap:ObjectPageSection
titleUppercase="false" id="idGeneralInfo" title="General Info">
<uxap:subSections>
<uxap:ObjectPageSubSection title="General Info" titleUppercase="false">
<form:SmartForm
id="SF1" class="editableForm" editTogglable="false" editable="true">
<form:Group id="G1">
<form:GroupElement id="GE-Cocode">
<smart:SmartField id="idCocode" value="{data>company_code}"/>
</form:GroupElement>
</form:Group>
<form:Group id="G2"> <form:GroupElement id="GE-Vendor">
<smart:SmartField id="idVendor" value="{data>vendor}"/>
</form:GroupElement>
</form:Group>
</form:SmartForm>
</uxap:ObjectPageSubSection>
</uxap:subSections>
</uxap:ObjectPageSection>
</uxap:sections>
</uxap:ObjectPageLayout>
</mvc:View>
Smart controls are designed to work with an odata model in order to render based on the service metadata. Don't use JSONModel. Instead, bind the object page to a single entity and use its properties in SmartFields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
akshayvjd07, please check the SmartField examples
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.