PDA

View Full Version : Send parameter to PHP ...



brebenel
11 Oct 2013, 4:12 AM
I want to populate a grid panel, recording only a particular user id.
How do I send my parameter (eg params {UserID: MyApp.User.getUserID ()}, the 'readContingente.php' after which I return only the records that belong to user connected.
Thank you for your help!

My store is:


Ext.define('MyApp.store.ListaContingente', {
extend: 'Ext.data.Store',

requires: [
'MyApp.model.ListaContingente'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
model: 'MyApp.model.ListaContingente',
storeId: 'StoreListaContingente',
proxy: {
type: 'ajax',
api: {
read: 'data/readContingente.php',
update: 'data/updateContingente.php',
create: 'data/createContingente.php',
destroy: 'data/deleteContingente.php'
},
reader: {
type: 'json',
root: 'data'
},
writer: {
type: 'json',
encode: true,
root: 'data'
}
}
}, cfg)]);
}
});


and in PHP:
...
$UserID = $_POST['UserID'];
SELECT * FROM tblContinget WHERE usr_id = $UserID
....

aconran
17 Oct 2013, 7:28 AM
Something like:


var ds = Ext.StoreMgr.lookup('StoreListaContingente');
ds.load({
params: {
UserID: MyApp.User.getUserID()
}
});


More details
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-load