javascript - Reading OData contexts in onInit of controller -
i've tried prepare data odata source show in bar graph in fiori app. this, setup odata model in manifest.json. test list, using
items="{path : 'modelname>/dataset'}
works fine , shows content.
to prepare data diagram (vizframe), used oninit() function in controller of view (mvc:xmlview). data preparation similar 1 discussed in question.
at first obtain odatamodel:
var oodatamodel = this.getownercomponent().getmodel("modelname");
next binding:
var obindings = oodatamodel.bindlist("/dataset");
unfortunately, obindings().getcontexts()
array empty, , obindings.getlength()
zero. consequence, vizframe shows "no data".
may data model not loaded during oninit() function, or misunderstand way access data?
thanks in advance
update temporary solved problem using automatically created bind view displaying data list. grep "datareceived" event binding getview().byid("mylist").getbindings("items")
, calculation there. model diagram (since used in different view) created in component.js, , registered in core sap.ui.getcore().setmodel("graphmodel")
. think solution dirty, because graph data depends on list data different view, causes problems, e.g. when use growing list (because data in binding gets updated , different range selected odata model). suggestions, how can odata model entries without depending on different list?
may data model not loaded during oninit() function, or misunderstand way access data?
you test if model loaded console log before list binding
console.log(oodatamodel); var obindings = oodatamodel.bindlist("/dataset");
if model contains no data, that's problem.
Comments
Post a Comment