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
    4,767
    Answers
    355
    Vote Rating
    164
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      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
    4,767
    Answers
    355
    Vote Rating
    164
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      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?

  8. #7
    Sencha User Arg0n's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    122
    Answers
    12
    Vote Rating
    16
    Arg0n will become famous soon enough Arg0n will become famous soon enough

      0  

    Default


    I would use a store, to save the data in it and load it from the other controller.

    I guess it could be also a problem with the asynchron behavior of ExtJs. But try it with a store first ^^

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

      0  

    Default


    Is it that difficult to pass a variable to another JS? I thought it will be as simple as passing a parameter to a PHP .

  10. #9
    Sencha User Arg0n's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    122
    Answers
    12
    Vote Rating
    16
    Arg0n will become famous soon enough Arg0n will become famous soon enough

      1  

    Default


    PHP runs synchron, so the whole scripts runs one time and finished. ExtJs uses alot of events. For that it must run the whole time to listen to the events. Because of that the MVC structur differs from PHP alot.

    You could also call a method in the other controller and pass the data to it.

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

      0  

    Default


    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 .

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar