Odata表没有显示odata记录

时间:2017-09-12 13:14:49

标签: uitableview sapui5

我可以存储odata记录,但这些记录不会显示在我的ui表上。

App.controller.js

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/m/MessageToast",
    "opensap/myapp/model/formatter",
    "opensap/myapp/controller/BaseController",
    "sap/ui/Device"
], function(Controller, MessageToast, formatter, BaseController, Device) {
        "use strict";

        return BaseController.extend("opensap.myapp.controller.App", {
            formatter: formatter,
            onInit: function() {
                // View in temasinin ayarlanmasi
                var oView = this.getView();
                var oComp = this.getOwnerComponent();
                oView.addStyleClass(oComp.getContentDensityClass());
                this.getRouter().attachRoutePatternMatched(this._onRouteMatched, this);

                //View in modelinin ayarlanamsı
                var oViewModel = this.getOwnerComponent().getModel();
                this.getView().setModel(oViewModel);

            },
            _onRouteMatched: function(oEvent) {
            var oController = this;
            var sRouteName = oEvent.getParameter("name");
            var oDataModel = this.getView().getModel();

            this._getAllMasrafs();
            this._getAllMasrafTips();
            },
            _getAllMasrafs: function(oEvent) {
                var oController = this;
                var oDataModel = this.getView().getModel();

                oDataModel.read("/GetMasrafSet", {
                    success: function(resp) {
                        var oMainModel = oController.getView().getModel("mainModel");
                        if (resp.results.length > 0) {
                            oMainModel.setProperty('/MasrafId', resp.results[0].MasrafId);
                            oMainModel.setProperty('/Tarih', resp.results[0].Tarih);
                            oMainModel.setProperty('/ProjeTanımı', resp.results[0].ProjeTanımı);
                            oMainModel.setProperty('/FişNumarası', resp.results[0].FişNumarası);
                            oMainModel.setProperty('/MasrafTipi', resp.results[0].MasrafTipi);
                            oMainModel.setProperty('/Tutar', resp.results[0].Tutar);
                            oMainModel.setProperty('/Para', resp.results[0].Para);
                            oMainModel.setProperty('/Kilometre', resp.results[0].Kilometre);
                            oMainModel.setProperty('/Lokasyon', resp.results[0].Lokasyon);
                            oMainModel.setProperty('/Açıklama', resp.results[0].Açıklama);
                        }
                    },
                    error: function(err) {
                    }
                });
            },
            _getAllMasrafTips: function(oEvent) {
                var oController = this;
                var oDataModel = this.getView().getModel();
                var oViewModel = this.getOwnerComponent().getModel("app");

                oDataModel.read("/GetMasrafTipiSet", {
                    success: function(resp) {
                        var oMainModel = oViewModel.getData();
                    /*  oMainModel.setProperty("/TAX", resp.results[0].TAX);
                        oMainModel.setProperty("/Taksi", resp.results[0].Taksi); */
                        oMainModel.Masraflar=resp.results;
                        oViewModel.setData(oMainModel);
                    },
                    error: function(err) {

                    }
                });
            },
            getRouter: function() {
                var oComponent = this.getOwnerComponent();
                return oComponent.getRouter();
            },
        });

当我按下F12选项并进行调试时,我可以看到我的数组存储在oMainModel但是我无法显示记录请帮帮我

我的错误在哪里? 谢谢 Cansu Koca

1 个答案:

答案 0 :(得分:0)

表“items”绑定中不得有“/”:

<Panel headerText="Masraf Listesi" expandable="true" expanded="false" >
                <content>
                    <Button press="_onMasrafListesi" text="Click here to see all Masrafs"/>
                    <Table id="idMasrafTable" items="{Masraf>Masraflar}" visibleRowCountMode="Auto">