cancel
Showing results for 
Search instead for 
Did you mean: 

Values is not displaying in object page for a particular list item from list page-Fiori

Akshayvjd07
Explorer
0 Kudos

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>

Accepted Solutions (0)

Answers (1)

Answers (1)

AlexNecula
Active Contributor
0 Kudos

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.

Akshayvjd07
Explorer
0 Kudos

can you please elaborate, I tried binding single entity but im not sure what is the diffrence or am i doing the right way

AlexNecula
Active Contributor
0 Kudos

akshayvjd07, please check the SmartField examples