PDA

View Full Version : pass variable



mohaskuar
29 Aug 2012, 11:38 PM
i hav a controller and my problem is how can i pass variables to my php file so that i can do a new query and fill my store as json out put....

redraid
29 Aug 2012, 11:42 PM
http://docs.sencha.com/ext-js/4-1/#!/guide/data

mohaskuar
30 Aug 2012, 12:42 AM
my controller

Ext.define('AM.controller.Users', {
extend: 'Ext.app.Controller',
views:[
'user.List','user.Edit','user.West','user.Tabview','user.ReportTree','user.SearchGrid',
],
stores:[
'Users','Policies','SearchGrids',
],
models: [
'User','Gridfill',
],
init: function() {
this.control({
'userlist': {
itemclick: this.searchUser
},
...........remaining codes....

});

},

searchUser: function(grid, record) {//the grid desplayed from userlist view
var searchId=record.get('id');

SearchGrids.load({params: searchId});
var view = Ext.widget('searchGrid');

},
......and on my php page

$sId=$_POST['searchId'];
then do query.....
// error SearchGrids is not defined and i tried this var SearchGrids= Ext.data.StoreManager.lookup('mystore'); and still the same error...what shall i do

vietits
30 Aug 2012, 1:05 AM
Did you try SearchGrids = Ext.data.StoreManager.lookup('SearchGrids')?

mohaskuar
30 Aug 2012, 1:21 AM
plus 'mystore' is the storeId of my store(SearchGrids);

redraid
30 Aug 2012, 1:51 AM
Controller add getters for stores:


searchUser: function(grid, record) {//the grid desplayed from userlist view
var SearchGrids = this.getSearchGridsStore(), // or SearchGrids = grid.getStore(),
searchId=record.get('id');

SearchGrids.load({
params: {
searchId: searchId
},
callback: function () {
// store loaded
}
});
},

mohaskuar
30 Aug 2012, 4:45 AM
the above
var SearchGrids= this.getSearchGridsStore();
SearchGrids.load({
params: {
searchId: searchId
},....... do exactly like i wanted but after loading the view which have a grid that uses SearchGrid the refresh button is not working....because..
$sId=$_POST['searchId']; on the php file would be null...after refreshing the grid....how can i solve that.....another is i used

var view=Ext.widget('SearchGrid');to load the view...so how can i close the first opend view before another one is loaded ....i tried this one

Ext.widget('SearchGrid').close(); but does not close it

redraid
30 Aug 2012, 7:10 AM
Use proxy extraParams:


searchUser: function(grid, record) {//the grid desplayed from userlist view
var SearchGrids = this.getSearchGridsStore(), // or SearchGrids = grid.getStore(),
searchId=record.get('id');

SearchGrids.proxy.extraParams.searchId = searchId;
SearchGrids.load(
callback: function () {
// store loaded
}
});

if (this.searchGridWin) {
// close opened window
this.searchGridWin.close();
//this.searchGridWin.destroy(); // if window closeAction != 'destroy' uncomment
this.searchGridWin = null;
} else {
this.searchGridWin = Ext.widget('SearchGrid');
this.searchGridWin.show();
}
},