1. #1
    Sencha Premium Member
    Join Date
    Nov 2007
    Location
    Sydney
    Posts
    58
    Vote Rating
    7
    Answers
    2
    CaCtus491 is on a distinguished road

      0  

    Default Answered: Improvements when adding a control new controller action

    Answered: Improvements when adding a control new controller action


    One of the frequent tasks when developing a project is adding new controller actions.

    My current process as of SA 3.0.4.1386 is:
    1. Select the controller to which the action should be added from the project inspector
    2. Start to type the word 'action' to filter the properties
    3. Select the plus icon to add a new action
    4. Select controller action
    5. Choose the target type
    6. Choose the action
    7. Go back to the project inspector and find the newly added action and click on it
    8. Fix up the controlQuery property
    9. Rename the fn name property
    10. Write the action code

    Is there a better process to follow than the above? With my current process, I have the following comments:
    • Steps (2) - (4) could be avoided if I could right click the controller in (1) and select 'Add controller action'
    • In step (5), life would be easier if the application views were listed in either alphabetical order, or at least the order in which they appear in the inspector.
    • If the selected application view has a userAlias defined, use that as the default selector rather than the xtype of the parent. If I wanted to create and action for 'panel' rather than the view with alias mypanel, I would have selected Ext.panel.Panel for the target rather than MyPanel in step (5).

    Any thoughts / comments?
    Last edited by CaCtus491; 15 Apr 2014 at 6:02 PM. Reason: Add current SA version

  2. This is one of my Fav. new features of SA 3! Instead of the way you are doing it, start with the component (button, form, grid, etc) that you want to trigger the action. Right click and select "add controller action" (btw, this is a great place to also add controller references). You tell it which controller, and Shazam! All you have to do is select the name of your function (action) and what event (click, edit, select) triggers it.My only gripe (which might be fixed soonish.... are you listening Sencha???) is that the control query JUST lists the component and not the parent container, so if I did that for an add button the query is "#addButton" and not "#customers #addButton" so I have to narrow the control query or EVERY add button will trigger this one action!

  3. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Connecticut
    Posts
    724
    Vote Rating
    126
    Answers
    8
    blomasky is a name known to all blomasky is a name known to all blomasky is a name known to all blomasky is a name known to all blomasky is a name known to all blomasky is a name known to all

      0  

    Default


    This is one of my Fav. new features of SA 3! Instead of the way you are doing it, start with the component (button, form, grid, etc) that you want to trigger the action. Right click and select "add controller action" (btw, this is a great place to also add controller references). You tell it which controller, and Shazam! All you have to do is select the name of your function (action) and what event (click, edit, select) triggers it.My only gripe (which might be fixed soonish.... are you listening Sencha???) is that the control query JUST lists the component and not the parent container, so if I did that for an add button the query is "#addButton" and not "#customers #addButton" so I have to narrow the control query or EVERY add button will trigger this one action!

  4. #3
    Sencha Premium Member
    Join Date
    Nov 2007
    Location
    Sydney
    Posts
    58
    Vote Rating
    7
    Answers
    2
    CaCtus491 is on a distinguished road

      0  

    Default


    Yes, this method is much better. After you pointed it out, I remember coming across it some time back. Not sure why it didn't stick.

    I agree with your suggestion of also including a reference for the parent container, however I'd like to extend that to be the itemId of the upper most parent container in the view. Usually I try to keep itemId's unique within a view, that way by setting the control query to a combination of the view's itemId and the component's itemId, I can move elements around in the view without needing to update any control queries.

    Perhaps the logic used to generate a control query could be a SA preference setting if there are multiple sensible ways in which to choose control queries (eg component only, component and component immediate parent, component and view, etc).

    On a side note, I find many of my buttons / tools have very short and simple code, so have started to add controller actions per view along the lines of 'onToolClick', then have a switch statement based on the itemId of the tool.

Thread Participants: 1