Skip to Content

Odata Model SetProperty, SetModel, GetModel Error

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Aug 20 at 06:57 PM

    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") ...
    Add a comment
    10|10000 characters needed characters exceeded