1. #1
    Sencha User
    Join Date
    Nov 2011
    Location
    Lille, France
    Posts
    31
    Answers
    2
    Vote Rating
    1
    Kakahn is on a distinguished road

      1  

    Default Answered: How Call a controller function from an another controller function

    Answered: How Call a controller function from an another controller function


    hello,
    I have a controller A with a method onTapItemList(),
    I have a second controller B with a method DisplayInformationOfEnterprise().
    I also have a view with the list and a view corresponding to the card details.
    Once caught with my event
    Code:
    '#Business-list': {
           itemtap: this.onTapItemOfList,
           scope: this
    }
    Code:
    onTapItemOfList: function (list, index, item, evt) {
            var = list.getStore company (). getAt (index);
            Ext.Viewport.setActiveItem (Ext.widget ('ficheEntreprise'));
    }
    How can I call a method of controller B to properly bind my second view with the enterprise informations ?

    Thanks

  2. You can do

    Code:
    this.getController('Controller Name').someFn()
    Watch for scoping

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      4  

    Default


    You can do

    Code:
    this.getController('Controller Name').someFn()
    Watch for scoping
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Touch Premium Member BostonMerlin's Avatar
    Join Date
    Aug 2010
    Location
    Boston
    Posts
    522
    Answers
    20
    Vote Rating
    41
    BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about

      2  

    Default


    just in case anyone needs this... the above answer has been deprecated. Docs suggest using..

    this.getApplication().getController() etc..

  5. #4
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Answers
    1
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default


    But getController() is in Private, isn't a problem?

  6. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    private only means that you shouldn't rely on it just like getController on the controller was deprecated but if it hasn't been deprecated then you can still use it just no guarantee it will be around forever. I personally don't see getController going away from application as that's how it inits the controllers.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #6
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Answers
    1
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default


    And what about best practices? Is there a better way of doing?

    You're telling me that's depreciated but use it since we use it... Why to depreciate it?

    Impossible to understand..!

  8. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The getController in the controller is deprecated but the getController in the application is not deprecated.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  9. #8
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Answers
    1
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default


    Ok, sorry for the misunderstanding. So it is private, but we are encourage to use it. Can you confirm there's no better way to do that? (Even if changing the way of doing?)

  10. #9
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Answers
    3500
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by mcbl View Post
    Ok, sorry for the misunderstanding. So it is private, but we are encourage to use it. Can you confirm there's no better way to do that? (Even if changing the way of doing?)
    Never encouraged you, just its private but that doesn't mean you can't use it. Personally I would fire events on the application and let the controller(s) listen to those events off the application instance to take action on it.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  11. #10
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Answers
    1
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default What about in Architect 2?

    What about in Architect 2?


    I don't see how to do that in Architect 2.
    1. There's no "event" in Architect 2, isn't it?
    2. Do you speak about Functions or Actions?
    I need to call another controller's function.