sapui5无法在详细信息页面中显示数据

sapui5无法在详细信息页面中显示数据,sapui5,Sapui5,我在“详细信息”页面中显示数据时遇到问题。我几乎什么都试过了,但都不管用。在主页上,一切看起来都很好。路由工作(在网络地址上显示正确的ID) Details.controller.js: return Controller.extend("sapProject.controller.Details", { onInit: function () { var oTable = this.getView().byId("details");

我在“详细信息”页面中显示数据时遇到问题。我几乎什么都试过了,但都不管用。在主页上,一切看起来都很好。路由工作(在网络地址上显示正确的ID)

Details.controller.js:

return Controller.extend("sapProject.controller.Details", {
        onInit: function () {
            var oTable = this.getView().byId("details");
            var oModel = new sap.ui.model.json.JSONModel();
            oModel.loadData("model/Object.json");
            oTable.setModel(oModel);
  var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
  oRouter.getRoute("Details").attachMatched(this._onRouteMatched, this);
},

        _onRouteMatched : function (oEvent) {
  var oArgs, oView;
  oArgs = oEvent.getParameter("arguments");
  oView = this.getView();
  oView.bindElement({
    path : "/Objects(" + oArgs.employeeId + ")",
    events : {
      dataRequested: function () {
        oView.setBusy(true);
      },
      dataReceived: function () {
        oView.setBusy(false);
      }
    }
  });
},

这是我的详细信息。view.xml:

    <Page
        id="details"

        title="{i18n>EmployeeDetailsOf} {FirstName} {LastName}"
        showNavButton="true"
        navButtonPress="onBack"
        class="sapUiResponsiveContentPadding">
        <content>
            <Panel

                width="auto"
                class="sapUiResponsiveMargin sapUiNoContentPadding">
                <headerToolbar >
                    <Toolbar>
                        <Title text="{i18n>EmployeeIDColon} {EmployeeID}" level="H2"/>
                        <ToolbarSpacer />
                    </Toolbar>
                </headerToolbar>
                <content>
                    <f:SimpleForm>
                        <f:content>
                            <Label text="{i18n>FirstName}" />
                            <Text text="{FirstName}" />
                            <Label text="{i18n>LastName}" />
                        </f:content>
                    </f:SimpleForm>
                </content>
            </Panel>
        </content>
    </Page>

我认为您正在将空模型绑定到详细视图,因为在表上设置模型时,
加载数据
功能可能未完成

尝试在清单(最佳选项)中加载json文件,或者在路径匹配函数上改变
\u onRouteMatched
上的
setModel
(尽管我在详细视图中没有看到任何表)

编辑: 您也可以在oModel.loadData(“model/Object.json”)之后使用此代码


首先,我建议您这样绑定:

var sObjectPath = this.getModel().createKey("Objects", {
            ID: oArgs.employeeId
        });
        this._bindView("/" + sObjectPath);
...
}


_bindView: function (sObjectPath) {
            //Todo: Set busy indicator during view binding

            this.getView().bindElement({
                path: sObjectPath,
                parameters: {

                },
                events: {
                    change: this._onBindingChange.bind(this),
                    dataRequested: function () {

                    }.bind(this),
                    dataReceived: function () {

                    }.bind(this)
                }
            });
        },

其次,检查oArgs.employeeId是否具有有效值,以及模型是否加载了数据,轻松设置brekapoint或write console.log(this.getView().getModel().oData)

控制台中是否有任何错误消息?
var sObjectPath = this.getModel().createKey("Objects", {
            ID: oArgs.employeeId
        });
        this._bindView("/" + sObjectPath);
...
}


_bindView: function (sObjectPath) {
            //Todo: Set busy indicator during view binding

            this.getView().bindElement({
                path: sObjectPath,
                parameters: {

                },
                events: {
                    change: this._onBindingChange.bind(this),
                    dataRequested: function () {

                    }.bind(this),
                    dataReceived: function () {

                    }.bind(this)
                }
            });
        },