javascript - SAPUI5 get current context in detail view -
javascript - SAPUI5 get current context in detail view -
i have sapui5 split-app master- , detail-view.
when select item in side bar, pass context detail view, lets product 1
onselectproduct: function(evt){ sap.ui.getcore().geteventbus().publish("app", "refreshproductdetail", {context : evt.getsource( ).getbindingcontext()}); },
this triggers next function binds context:
refresh: function(channelid, eventid, data){ if (data && data.context) { this.getview().setbindingcontext(data.context); } },
now when perform action save, want current info of product 1 in model.
however, when utilize
this.getview().getbindingcontext().getmodel()
it returns model products. how know 1 beingness viewed user?
you can utilize getpath()
of bindingcontext see object displayed:
this.getview().getbindingcontext().getpath();
you this:
var bindingcontext = this.getview().getbindingcontext(); var path = bindingcontext.getpath(); var object = bindingcontext.getmodel().getproperty(path);
if want property of displayed object can this:
var property = bindingcontext.getproperty("<nameofproperty>");
which returns property of object @ specific context.
update:
you can phone call getobject()
of bindingcontext returns object in model current context points to:
var object = bindingcontext.getobject();
see documentation of context more information.
javascript model-view-controller sap sapui5
Comments
Post a Comment