-
21 Nov 2012 12:16 AM #1
Getting store saved records on server
Getting store saved records on server
Hello,
I created a grid panel with a store.
Data are from a PHP script.
It is possible to modify data in the grid (rowEditing) and to update the store.
When the user click on a button in the grid toolbar, data are sent to a PHP script on the server. I can see it in Firebug.
The question is : how can I get the data transmitted in PHP ? I can't see them in the POST or the GET variables... I think it's very simple, but I can't do it.
firebug_nov.png
Gilles
-
21 Nov 2012 4:00 AM #2
Hi gfevrier,
How are you using the submit?I am sorry my english, I am learning yet
Portuguese blog: http://wessdevel.blogspot.com.br/
Twitter: @wlegolas
-
21 Nov 2012 4:46 AM #3
Hi,
This is the code :
And in the grid definition :Code:var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { clicksToMoveEditor : 2, autoCancel : false }); if (Ext.grid.RowEditor) { Ext.grid.RowEditor.prototype.saveBtnText = "Mettre à jour"; Ext.grid.RowEditor.prototype.cancelBtnText = "Annuler"; } Ext.define('Enfants', { extend: 'Ext.data.Model', fields: [ { name : 'id_enfant' , mapping : 'id_enfant' }, { name : 'nom' , mapping : 'nom' }, { name : 'prenom' , mapping : 'prenom' }, { name : 'ville' , mapping : 'ville' }, { name : 'commentaire' , mapping : 'commentaire' }, { name : 'distribution' , mapping : 'distribution' } ], idProperty: 'id_enfant' }); listeEnfantsStore = Ext.create('Ext.data.Store', { id : 'listeEnfantsStore', model : Enfants, proxy : { type : 'ajax', method : 'POST', reader : { type : 'json' }, writer : { type : 'json' }, api : { read : 'ajax/liste_enfants.php', update : 'ajax/enregistre_enfants.php' } }, autoLoad : true });
Data are thrown to server when I call the "sync" method on the "listeEnfantStore" store.Code:plugins : [rowEditing], tbar : [{ text : 'Enregistrer les données', handler : function() { listeEnfantsStore.sync(); } }]
Thanks for your help.
Gilles
-
21 Nov 2012 7:25 AM #4
gfevrier, you need to inform in your Writer the parameter name for submit this record:
See in API Doc the class "Ext.data.writer.Json" for more informations.Code:listeEnfantsStore = Ext.create('Ext.data.Store', { id : 'listeEnfantsStore', model : Enfants, proxy : { type : 'ajax', method : 'POST', reader : { type : 'json' }, writer : { type : 'json', // Added a new properties encode: true, nameProperty: 'mapping', root: 'data' // Important }, api : { read : 'ajax/liste_enfants.php', update : 'ajax/enregistre_enfants.php' } }, autoLoad : true });
In your PHP you can get this object by parameter $_POST["data"].I am sorry my english, I am learning yet
Portuguese blog: http://wessdevel.blogspot.com.br/
Twitter: @wlegolas
-
21 Nov 2012 9:31 AM #5
Yeeeeessssssss !!! Thank you very very much ! I read the documentation but I haven't understood it in the right way...

It works well know !
Gilles


Reply With Quote