I have successfully completed this great tutorial : http://www.sencha.com/learn/ext-js-grids-with-php-and-sql/
I just can't use the baseParams field specified with the proxy... Here is my code that follows tutorial description :
__ My Store : Communes.js ____
Ext.define('app.store.Communes', {
extend: 'Ext.data.Store',
id: 'communesstore',
requires: ['app.model.Commune'],
config: {
model: 'app.model.Commune',
departement:'var',
// the proxy with POST method
proxy: new Ext.data.HttpProxy({
url: 'app/php/communes.php', // File to connect to
method: 'POST'
}),
// the parameter passed to the proxy
baseParams:{
departement: "VAR"
},
// the JSON parser
reader: new Ext.data.JsonReader({
// we tell the datastore where to get his data from
rootProperty: 'results'
},
[
{
name: 'IdCommune',
type: 'integer'
},
{
name: 'NomCommune',
type: 'string'
}
]),
autoLoad: true,
sortInfo:{
field: 'IdCommune', direction: "ASC"
}
}
});
_____ The php file : communes.php _____
<?php
/**
* CREATE THE CONNECTION
*/
mysql_connect("localhost", "root", "pwd") or
die("Could not connect: " . mysql_error());
mysql_select_db("databasename");
/**
* INITIATE THE POST
*/
$departement = 'null';
if ( isset($_POST['departement'])){
$departement = $_POST['departement']; // Get this from Ext
}
getListCommunes($departement);
/**
*
*/
function getListCommunes($departement) {
[CODE HERE WORK FINE : just a connection and query but $departement is NULL]
}
?>
There is no parameter passed as POST method... Any idea?