1. #1
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Luxembourg
    Posts
    193
    Vote Rating
    2
    EAHC-IT is on a distinguished road

      0  

    Default Create a (global) basic function

    Create a (global) basic function


    Hello,

    How can I create through the designer a basic function that can be instantiated from anywhere;
    I can not drop the behaviour basic function over the Application.
    I was expecting invoking from different controllers a "global" function.
    Code:
    Ext.app.fnEnableMenu(sParams);
    or 
    myApp.fnEnableMenu(sParams);
    Thank you

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,249
    Vote Rating
    121
    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  
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Luxembourg
    Posts
    193
    Vote Rating
    2
    EAHC-IT is on a distinguished road

      0  

    Default


    Thank you; I already read that thread.
    At this stage, it is not possible to add a fn through the designer at the Application level ?

    When I give a try to the code solution.
    But I get
    Code:
    Uncaught TypeError: Object [object Object] has no method 'fnEnableMenu'
    
    I invoke the a Fn located in a Controller
    Code:
    Ext.define('GrantCycle.controller.c_fp_auth', {
        extend: 'Ext.app.Controller',
    ...
    }
    ,
    
    
        fnEnableMenu: function(sRights) {
            //console.log(sRights);
            if (sRights.indexOf('ADM') != -1) {
    ...
    from another Controller
    Code:
    Ext.define('GrantCycle.controller.c_p_adm_users', {
        extend: 'Ext.app.Controller',
    ...
    ,
    
    
        Click_b_s_f_adm_user_manage: function(button, e, options) {
            Ext.getCmp('p_adm_users_fp').getForm().submit({
                method: 'POST',
                scope: this,
                url: '_cfm/set/update_user.cfm?loc_useralias=' + loc_useralias,
                waitTitle: 'Connecting',
                waitMsg: 'Sending data...',
                clientValidation: true,
                success: function(){
                    Ext.getCmp('t_adm_user_manage_quickfilter').fireEvent('keyup');
                    this.application.fnEnableMenu();
                    Ext.defer(function() {
                        Ext.Msg.show({
                            title: 'Form Submitted',
                            msg: 'Success',
                            width: 400,
                            buttons: Ext.MessageBox.OK,
                            icon: Ext.MessageBox.INFO,
                            maxWidth: 400
                        });
                    }, 100);
                }
    ...
    I tried, without success
    Code:
    GrantCycle.controller.c_fp_auth.application.fnEnableMenu();

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


    hrmmm you added it to the controller, not to the application.

    You can invoke it like so:
    Code:
    this.getController('c_fp_path).fnEnableMenu();
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  5. #5
    Ext JS Premium Member
    Join Date
    Dec 2010
    Location
    Luxembourg
    Posts
    193
    Vote Rating
    2
    EAHC-IT is on a distinguished road

      0  

    Default


    Thank you.
    I will give a try to your solution.

    Byt the way, yes, I would prefer put "global" function at the application level and not within a controller but I can not add (through the Designer) the "Application Action" outside a controller? Do I have to create a controller that would contains all my "global" functions? I was expecting dropping the "Application Action" on the Application root node of the project inspector so the function would be created below the Launch default function.

    Or I miss something...

    Thank you for your time and support,
    Jean-Philippe

Thread Participants: 1