Skip to Content
0
Aug 20, 2020 at 03:50 PM

Odata Model SetProperty, SetModel, GetModel Error

132 Views

Hello Experts,

Below is my code:

that.oModel.read("/ZDB_DETAIL", {
                            filters: aFilter_Detail,
                            success: function(oData, oResponse) {
                                    var oModel_DetailModel = new sap.ui.model.json.JSONModel();
                                    var data = {
                                        "detailDataRows": oData.results
                                    }
                                    oModel_DetailModel.setData(data);
                                    that.getView().setModel(oModel_DetailModel , "DATA_DETAIL");
                                    }.bind(that),
                            error: function(request, error) {
                                sap.m.MessageToast.show("No Data exists.");
                                that.FLAG_NEW = true;
                                that.onInitGenerateRows;
                            }.bind(that)
                 

In the below method: I am trying to get the property "/detailDataRows" from the model. But it returns undefined. All the oData.results are in object form instead of one object detailDataRows : [ oData.results] .

onAdd: function() {
            debugger;
            var oModel = this.getView().getModel().getProperty("/detailDataRows"); // undefined
}

Can anyone help me how to set a new property to the model?

Thanks & Regards,

Zayid