cancel
Showing results for 
Search instead for 
Did you mean: 

JSON getProperty is undefined

former_member188556
Active Contributor
0 Kudos

Hello All,

I am getting which works fine, only after page is loaded

this.getOwnerComponent().getModel("tiles").getProperty("/d/results");

But I am getting a undefined when using the same code in oInit() or afterRendering() methods. Surprisingly(to me, atleast) is not null and oData can be seen in the oModel object in console

this.getOwnerComponent().getModel("tiles");

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor

What's ur code to load that json?

make it synchronous

former_member188556
Active Contributor
0 Kudos

Hello Jun

I use the manifest.json to load the json, the json is a local file.

Regards

Bobu George

junwu
Active Contributor
0 Kudos

ask to load it synchronously

former_member188556
Active Contributor
0 Kudos

Hello Jun,

how would you do that in the manifest.json ?

Regards

Bobu George

junwu
Active Contributor
0 Kudos

seems no way. you can use code to load the json data, not big deal.

Answers (1)

Answers (1)

kammaje_cis
Active Contributor

As I understand, Model is not yet loaded with data during onInit and afterRendering.

former_member188556
Active Contributor
0 Kudos

Krishna

If I put a breakpoint at the location in onInit or afterRendering, I could see json model in the oData section in the model.

Also, from the network console, I can see all the models being called and completed before the view.xmls being called.

Regards

Bobu George

former_member188556
Active Contributor
0 Kudos

As you can see, this is the console output of the below code in onInit

this.getOwnerComponent().getModel("tiles");

But when I use the below code, its returning null in onInit

this.getOwnerComponent().getModel("tiles").getProperty("/d/results");

Also from the below network console, you can see that the models are loaded and then only the view controllers are loaded.