0

我有一个带有搜索按钮的页面。单击“搜索”按钮时,我正在尝试显示产品及其详细信息。我成功地在我的“odata”中获取数据,我可以在我的控制台中看到它。但是我没有看到我的表并且我收到错误“断言失败:EventProvider.attachEvent:fnFunction 必须是一个函数”我正在我的控制器中执行所有表声明 n 显示。MaterailSet 在我的后端的实体集中,所有 5 列数据。我在绑定中做错了什么。

onInit: function () {
        var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/Z_MATERIAL_LIST_SRV/");
        sap.ui.getCore().setModel(oModel);

    },
    onSearchProduct: function (oEvt) {

        var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/Z_MATERIAL_LIST_SRV/", true);
        var oJsonModel = new sap.ui.model.json.JSONModel();

        oModel.read("/MaterialSet", {
            success: function (oData, oResponse) {
                oJsonModel.setData(oData);
                sap.ui.getCore().setModel(oJsonModel,"MaterailSet");
            },
            error: function (oError) {
                // Error Handling Here by divya
            }
        });

        var oTable = new sap.ui.table.Table();

        oTable.addColumn(
            new sap.ui.table.Column({
                label: new sap.ui.commons.Label({
                    text: "MaterialNumber"
                }),

                template: new sap.ui.commons.TextField({
                    value: "{MaterialNumber}"
                }),
                width: "100px"
            }));
        // 2nd column “MaterialDescription”
        oTable.addColumn(new sap.ui.table.Column({
            label: new sap.ui.commons.Label({
                text: "MaterialDescription"
            }),
            template: new sap.ui.commons.TextField({
                value: "{MaterialDescription}"
            }),
            width: "100px"
        }));
        // 3rd column “MaterailType”
        oTable.addColumn(new sap.ui.table.Column({
            label: new sap.ui.commons.Label({
                text: "MaterailType"
            }),
            template: new sap.ui.commons.TextField({
                value: "{MaterailType}"
            }),
            width: "100px"
        }));
        // 4th column “MaterailGroup”
        oTable.addColumn(new sap.ui.table.Column({
            label: new sap.ui.commons.Label({
                text: "MaterailGroup"
            }),
            template: new sap.ui.commons.TextField({
                value: "{MaterailGroup}"
            }),
            width: "100px"
        }));
        // 5th column “MateriialUnit”
        oTable.addColumn(new sap.ui.table.Column({
            label: new sap.ui.commons.Label({
                text: "MateriialUnit"
            }),
            template: new sap.ui.commons.TextField({
                value: "{MateriialUnit}"
            }),
            width: "100px"
        }));

        oTable.setModel(oJsonModel);
        oTable.bindRows("MaterialSet>/MaterialSet");

        return oTable;
4

0 回答 0