cancel
Showing results for 
Search instead for 
Did you mean: 

Odata Model SetProperty, SetModel, GetModel Error

zayidu
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

pfefferf
Active Contributor

When attach the model to the view you have used the name "DATA_DETAIL". You have to use the same name when you retrieve the model from the view.

this.getView().getModel("DATA_DETAIL") ...