Hybrid View
-
30 Nov 2012 6:46 AM #1
Answered: Sending parameter to js
Answered: Sending parameter to js
Hi,
I have a varialble in Controller like,
I want to use this arrayValues in another js in another location, I am doing,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] } }); ...
But I am not getting the value there, how should I do to get the selected value?Code:groupField: MyApp.controller.MyController.param1
-
Best Answer Posted by sencha.user
Hi,
It worked like this,
Can then access using MySharedData.foo, for instance.Code:Ext.define('MySharedData', { singleton: true, foo: 'bar', meh: 42 });
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
.
-
30 Nov 2012 8:20 PM #2
When you create your application in the Ext.application's init function do this:
Then you'll have access to the application using MyApp.app. From there you can do:Code:init: function () { MyApp.app = this; }
Code:groupField: MyApp.app.getController('MyController').param1; // provided param1 is a property of the controller itself
-
4 Dec 2012 1:23 AM #3
This isn't working, when I alert,
in the new file, it says "undefined"Code:MyApp.app.getController('MyController').param1
.
-
4 Dec 2012 4:05 AM #4
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?
-
4 Dec 2012 4:43 AM #5
It just shows something like this,
When I click for more info, there are lots of data, but there isn't anything related to param1Code:Object { application={...}, id="MyController", hasListeners={...}, more...}
.
Forget about parameters, I have this variable in controller,
I have to have this variable in another js, groupData like that,Code:var groupData = Ext.ComponentQuery.query('#groupid')[0].getValue();
How should I do this?Code:groupField: groupData
Thanks for the reply BTW
.
-
4 Dec 2012 8:37 PM #6


Reply With Quote