1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    411
    Vote Rating
    2
    parky128 is on a distinguished road

      0  

    Default Can a controller action call a basic function?

    Can a controller action call a basic function?


    Hi,

    I have some combo's which I need to call a common basic function if the select or change events fires for any of these. At the moment they are calling specific select and change functions like so:

    Code:
    Ext.define('PPExtranet.controller.Customer', {
        extend: 'Ext.app.Controller',
    
    
        init: function() {
            this.control({
     
                "#cmbCustomerFilter": {
                    select: this.onCmbCustomerFilterSelect,
                    change: this.onCmbCustomerFilterChange
                }
            });
    
    
            var me = this;
    
    
        },
    
    
        onCmbCustomerFilterSelect: function(field, value, options) {
            console.log('cmbCustomerFilterSelect cstName now: '+value[0].data.Name);
    
    
          },
    
    
        onCmbCustomerFilterChange: function(field, newValue, oldValue, options) {
            console.log('cmbCustomerFilterChange cstName now: '+newValue);
        },
    
    
        filterCustomersStore: function() {
    
    
        }
    
    
    });
    But I now want them to call a common basic function (i need to do some custom filtering on a store), however if I try and change the function name in Designer on my select and change controller actions, Designer wont let me saying that the function name is already in use or reserved.

    Does this mean in the current select and change handler functions above, I then need to make a call to my basic function?

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,413
    Vote Rating
    129
    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


    You are correct in your assumptions.

    In the above situation both onCmbCustomFilterSelect/onCmbCustomFilterChange should invoke filterCustomersStore. You can do this via this.filterCustomersStore();

    We don't allow binding of a single function to multiple events because even though you can do it when using raw js it can be a source of bugs and frustration. As you can see above the arguments to the function are not the same. How do you know which one to use and where it came from, etc, etc.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

Thread Participants: 1