Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

working with Fragment's controller

Hello Folks,

I created a fragment which holds some control( table and a button in my case ). I created separate controller for Fragment.

I added the fragment to the view dynamically in onInit of the view controller.

onInit : function(){

  var f = new oFrg();

  var fc = sap.ui.xmlfragment(this.createId("f1"), "testfrg.view.test", f);

  this.getView().byId("page1").addContent(fc);

}

Now i have everything in View.

on click of button i want to do some operation to table so to get the table from fragment i have to pass id like below:

var t = sap.ui.getCore().byId("__xmlview0--f1--Table");  // f1 is fragment id and Table is table id

__xmlview0-- is getting concatenated since the event handler is in fragment own controller.

If the same event handler will be in view controller we can access table by only giving fragment id and the table id using sap.ui.core.Fragment.createId(sFragmentId, sId)

Now if i provide the id to my xmlview (lets say View1 ) then the same controller id will be concatenated with

__component0--View1--f1--Table

My question is how to get rid of __component0--View1 ?

or what is the way to get the controle of fragment into its controller.

Thanks for your input.
Abhi

Tags:
Not what you were looking for? View more on this topic or Ask a question