cancel
Showing results for 
Search instead for 
Did you mean: 

problem : model.getProperty

former_member186158
Active Participant
0 Kudos

var mm = new sap.ui.model.json.JSONModel();

mm.loadData("/test/deputy/handler/init",true,"GET",false,"true",null);

sap.ui.getCore().setModel(mm);

.....

-


then I want to get data from the model;

//

     var me = mm.getProperty("/startBy");

dosomething(me);

...

But  got  me : undefined

the json data like this:

{"formId":null,"formName":null,"startBy":"00091897","applicant":null,"deputy":null,"startDate":"2013-07-02","endDate":"2013-07-02","posId":null,"appType":null,"reasonType":null,"reasonText":null,"nameA":null,"nameB":null,"comments":null}

Anyone can help me?

Accepted Solutions (1)

Accepted Solutions (1)

former_member293602
Active Participant
0 Kudos

Hi Shen,

this could be a matter of "timing". When calling the "loadData" method, you trigger an async request. This means, that when you try to get a property from the model there is no guarantee that the data is loaded already. You might consider registering an event handler on the "RequestCompleted" event of the model. Please refer to the API reference for more details.

Regards, Frank

former_member186158
Active Participant
0 Kudos

problem solved.

Thanks very much.

Former Member
0 Kudos

Hi Frank,

just a few days ago, I had the same issue. And even after a "RequestCompleted" event, the data was sometimes not loaded ("undefined").

Only fix I found was an additional setTimeout for about 300ms. But this is of course not a desired solution...

Regards

Stefan

Former Member
0 Kudos

Hi Shen

How you fix this problem?

Thanks

Answers (1)

Answers (1)

Former Member
0 Kudos

This message was moderated.