Hybrid View

  1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    69
    Vote Rating
    0
    mboreback is on a distinguished road

      0  

    Default Reuse of top level components and event handling

    Reuse of top level components and event handling


    I am unclear of how to capture events from a linked top levelel component.

    Sencha designer offers a nice way to reuse components, but I have not found any good documentation on how to add event handling on the instance.

    I have found no way to add events to the instance in a view and not ether a way to do it on the controller for a specific instance.

    A basic example is that I have a class that contains a list.
    I reuse this class in multiple view by linking the class to my view.
    When itemtap event is generated in the linked instance I like to handle this in my active view and consume the information in same way as I can do if I had defined this list within the view.


    I have read documentation on MVC but not found a solution for this.

    But it is very nice to only have one copy of this class and reuse it in all views.

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,365
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Not sure if this answers your question, feel free to ask more specific questions...

    In the (Designer) section of the property grid there is an Events row. Click the + next to it to add event handlers to your class.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    69
    Vote Rating
    0
    mboreback is on a distinguished road

      0  

    Default


    To explane it a bit more.
    I have a cardpanel containg a list and one form
    The form has a field named projectId, that is updated when itemTap event is triggered in the list.

    But If I now promote my list to be a Class, itemTap in list will not update my form anymore.
    Yes it is simple to chnage the itemTap in the list to find the form and then update the field.
    But
    If I now add a new card panel that looks the same as the first on, and link my list into this card panel, I have a problem.

    With linked classes there is no way to add an event to the instance.
    So my problem is that I am reusing a tp level class in multiple other classes, and want to att an event to the instance of the list so it can update the corect form.

    Any hints for a solution?

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,365
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    I understand now. For a concrete example:

    Start an Ext 4.x project
    Drag out a TabPanel
    ...
    Customize the TabPanel
    ...
    Link the TabPanel to both a top level Window and then a top level Panel

    You would like to add event handling to an event of TabPanel for a specific instance. Like adding an event handler for tabchange only when used in the Window.

    We don't handle this in a graceful way yet. You can override initComponent via an overrides file for that class and then add in additional event handling for that specific Window instance.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  5. #5
    Sencha User
    Join Date
    Sep 2010
    Posts
    69
    Vote Rating
    0
    mboreback is on a distinguished road

      0  

    Default


    delegatedEvent.jpgWhat about delegated events can they be used to solve this?

    I played around with sencha touch in sencha designer with a button and that worked, but when I tryed the same thing with a list it did not.
    Last edited by mboreback; 11 Apr 2012 at 2:25 PM. Reason: Adding more detailes

  6. #6
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,365
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Delegated events should work as long as you specify the proper targettype
    Aaron Conran
    @aconran
    Sencha Architect Development Team

Thread Participants: 1