cancel
Showing results for 
Search instead for 
Did you mean: 

working with Fragment's controller

former_member185241
Active Participant
0 Kudos

Hello All,

I posted in SCN my query. now it is here with archive. I can not edit it seems.

http://archive.sap.com/discussions/thread/3965941

My query is still open.

jun.wu5 : Yes i am sure even core will not resturn the referance when we call it in fragments controler .

Thanks,
Abhi

Accepted Solutions (1)

Accepted Solutions (1)

former_member227918
Active Contributor
0 Kudos

Hello,

I didn't work with separate controller of fragments, but you can get table by using jQuery and their dom.

try this,

var oTable = $( "table[id*='idTable']" ).control()[0]; // replace idTable with your table id only, not along with view or
fragment id.

Hope this will help you.

Rgards,

Akhilesh

,

Hello,

I didn't work with separate controller of fragment, but you can get table by using jQuery and their dom.

Try this,

var oTable = $("table[id*='idTable']").control()[0]; // replace idTable with your table id only, not along with fragment
or view id.

Hope this will help you.

-Akhilesh

former_member227918
Active Contributor
0 Kudos

sorry, due to bug of new platform, my comment appearing twice, first time I didn't see my comment then i posted again.

agentry_src
Active Contributor
0 Kudos

Oddly enough, it was probably not a bug that kept your first comment from being visible. Well, maybe, sort of. Your content appears to have met the requirement of Pre-Moderation (Moderator review prior to posting). You should have seen a message which indicated the delay when you posted it.

I am not sure what your status is at the moment, but you may still be subject to such a review.

Regards, Mike (Moderator)

SAP Technology RIG

former_member227918
Active Contributor
0 Kudos

I am not sure, but scenario was,

first time when submitted my answer one error message came and crashed the discussion page (didn't remember the exact error message).

then I came back to this discussion again and didn't see my posted content, then I entered my answer again and press submit button, after submit button pressed the result is above you can see.

-Akhilesh

Answers (3)

Answers (3)

former_member185241
Active Participant
0 Kudos

Hello Emanuel,

We can create fragments own controller as documented:

https://sapui5.hana.ondemand.com/docs/api/symbols/sap.ui.html#.fragment

So we have sap.ui.fragment(sName, sType, oController?), If we pass the controller name in oController while defining the fragment then we can write event handler of each control (from fragment) into this controller. No need to go to View controller for that.

Thanks,

Abhi

former_member185241
Active Participant
0 Kudos

Hello Emanuele,

I can not get the control using byId("Table") as i am writing it in fragment controller . this will work when writing in view controller.

Thanks,

Abhi

ericci
Active Contributor
0 Kudos

Hi Abhishek, Fragment are just Stub, they don't have a Controller. When you add a Fragment inside a view they're using the View's Controller

ericci
Active Contributor
0 Kudos

Hi Abhishek,

if your problem is just to take the table control you can do

this.getView().byId("Table") 

where Table is the id of your table inside the fragment.and this is the controller

ericci
Active Contributor
0 Kudos

Hi Michael what is stuckin the moderator queue? I'm a blacklisted ? 😄

former_member185241
Active Participant
0 Kudos

Hello Emanuele,

I am accessing the Table in Fragments controller . So i can not acces the control using byId("Table").

this.getView().byId("Table") will work when i write this in View controller