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;