Skip to Content

working with Fragment's controller

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 17, 2016 at 08:04 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Oct 12, 2016 at 10:59 AM

    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

    Add comment
    10|10000 characters needed 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
  • Oct 12, 2016 at 11:31 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 12, 2016 at 02:21 PM

    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

    Add comment
    10|10000 characters needed characters exceeded