0

I have a Page with Search button. On clicking on Search button i am trying to display products and their details. I am successfully fetching the data in my "odata" , I can see that in my console. However i dont see my table and i get error " Assertion failed: EventProvider.attachEvent: fnFunction must be a function " I am doing all the Table declare n display in my controller. MaterailSet in my Entityset from Backend which all all the 5 column data. What am i doing wrong in my Binding.

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;
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Winona
  • 115
  • 1
  • 17
  • 1
    `sap.ui.commons` is deprecated. Also what is the point of using an OData model and then not using the OData model but copying the data into another (JSON) model? – Marc Apr 09 '20 at 06:26
  • 1
    Hi Winona. As @Marc pointed out, there are many common mistakes that a lot of beginners usually make. To avoid such anti-patterns, I **strongly** encourage, [again](https://stackoverflow.com/questions/60814017/navigating-to-a-different-jsview-unable-to-access-router/60826907#comment107642033_60826907), to invest some time in reading the [doc](https://openui5.hana.ondemand.com/topic) first. If something is not clear, feel free to [create an issue on GitHub](https://github.com/SAP/openui5-docs/issues). – Boghyon Hoffmann Apr 09 '20 at 11:03

0 Answers0