Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3184

Global or named models and data loading

$
0
0

To provide a nice starting screen, I'm using an IconTabBar with several tabs. Each tab has its own MVC to load data and handle use interaction.

 

One of the IconTabFilter properties is 'count', in which you can display a number.

 

Let's say I would like to have a tab 'Products' and show the number of products that are in the json file. Reading the file is working and is being done in the controller for the Products tab. Allrighty, so there I have my number, there are 4 records in the file. But now I have no reference to the App controller or view to change the 'count' property.

 

Turning it around, I can pre-load all data into the model using the App controller. Once again, I find 4 records and now I can set the 'count' property in my view. However, when clicking the Products tab, my data is not there yet... I still have to bind a model to the view. That then has to be the model already loaded in the App... but here I run into the same problem... how to reference to it?

 

What I've tried is using named models in the App controller:

var oProductsModel = new JSONModel();

oProductsModel.loadData("data/products.json");

sap.ui.getCore().setModel(oProductsModel, "productsModel");

...and later in the Products controller...

oModel = sap.ui.getCore().getModel("productsModel");

But even then not returning the data I'm expecting.

 

And perhaps I'm even looking at this the wrong way, still getting the hang of working with UI5 and MVC How should I solve this one?


Viewing all articles
Browse latest Browse all 3184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>