javascript - why formatter doesn't work in fragment xml? -
there formatter function in other lib , aim use function. here formatter.js :
sap.ui.define([], function () { "use strict"; var formatter = { showasdate : function(str){...} }; return formatter; });
and in fragment i'm using below :
<text text="{ path: 'jsonmodel>/date', formatter : '.formatter.showasdate' }" />
and call formatter.js in controller below:
sap.ui.define(["libpath/formatter"], function (formatter){ "use strict"; return controller.extend("controller.mycontroller", { formatter : formatter, //i add fragment myview method //and calling method in oninit. _showformfragment : function (sfragmentname) { var opage = this.getview().byid("page"); opage.removeallcontent(); opage.insertcontent(this._getformfragment(sfragmentname)); } }); });
i using openui5beta library.and coded view , controllers according walkthrough sapmle. , can see similar usage in invoicelist.controller.js, invoicelist.view.xml, hellodialog.fragment.xml . these samples show how reach formatter view not fragment. able reach formatter.js myview.view.xml can't reach fragment.any appreciated.
can share how fragment invoked? when fragment invoked have additional parameter specify js object context this
var ofragment = sap.ui.xmlfragment("yourfragment.xml",this);
the above code called in controller "this" refer controller instance , format functions should work.
Comments
Post a Comment