Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default Answered: Sending parameter to js

    Answered: Sending parameter to js


    Hi,

    I have a varialble in Controller like,

    Code:
    Ext.define('MyApp.controller.MyController', {
        extend: 'Ext.app.Controller',
        onFieldButtonClick: function(button, e, options) {
        var groupChecked = Ext.getCmp('groupgrid').getSelectionModel().getSelection();
            var arrayValues = [];
            Ext.each(groupChecked, function(rec, index) {
                arrayValues.push(rec.get('colName'));
            });
        var MyGrid = Ext.ComponentQuery.query('MyGrid')[0];
                        MyGrid.getStore().reload({
                            params:{
                                singleton: true,
                                param1: [arrayValues]
                            }
                        });
    ...
    I want to use this arrayValues in another js in another location, I am doing,
    Code:
    groupField: MyApp.controller.MyController.param1
    But I am not getting the value there, how should I do to get the selected value?

  2. Hi,

    It worked like this,
    Code:
    Ext.define('MySharedData', {
        singleton: true,
    
        foo: 'bar',
        meh: 42
    });
    Can then access using MySharedData.foo, for instance.

    Found in,
    http://www.sencha.com/forum/showthre...ble-in-Extjs-4

    Didn't try it correctly initially, now works good, it doesn't do grouping like expected anyway .

  3. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,462
    Answers
    440
    Vote Rating
    202
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      1  

    Default


    When you create your application in the Ext.application's init function do this:

    Code:
    init: function () {
        MyApp.app = this;
    }
    Then you'll have access to the application using MyApp.app. From there you can do:

    Code:
    groupField: MyApp.app.getController('MyController').param1;    // provided param1 is a property of the controller itself

  4. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default


    This isn't working, when I alert,

    Code:
    MyApp.app.getController('MyController').param1
    in the new file, it says "undefined" .

  5. #4
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,462
    Answers
    440
    Vote Rating
    202
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    If you do console.log(MyApp.app.getController('MyController')) do you see the param1 property in the list? Do you see any other properties / methods belonging to MyController?

  6. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default


    It just shows something like this,

    Code:
    Object { application={...},  id="MyController",  hasListeners={...},  more...}
    When I click for more info, there are lots of data, but there isn't anything related to param1 .

    Forget about parameters, I have this variable in controller,

    Code:
    var groupData = Ext.ComponentQuery.query('#groupid')[0].getValue();
    I have to have this variable in another js, groupData like that,

    Code:
    groupField: groupData
    How should I do this?

    Thanks for the reply BTW .

  7. #6
    Sencha User
    Join Date
    Jul 2012
    Posts
    107
    Answers
    4
    Vote Rating
    -1
    sencha.user is an unknown quantity at this point

      0  

    Default


    Anyone?

Thread Participants: 2