Skip to Content
0

working with Fragment's controller

Oct 12, 2016 at 10:48 AM

236

avatar image

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 Wu : Yes i am sure even core will not resturn the referance when we call it in fragments controler .

Thanks,
Abhi

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Akhilesh Upadhyay Oct 17, 2016 at 08:04 AM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

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

0

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

0

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

0
Emanuele Ricci Oct 12, 2016 at 10:59 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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
0
Abhishek Sinha Oct 12, 2016 at 11:31 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
Abhishek Sinha Oct 12, 2016 at 02:21 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded