PDA

View Full Version : How to send data from Grid ?



kolbek
19 Jun 2009, 12:02 AM
Hi,

Is it possible to send data to php from an Ext Grid ?

Thanks you.

19 Jun 2009, 3:38 AM
var records = store.getRange();

var recordsToSend = [];

records.data.each(function(record) {
recordsToSend.push(record.data);
});

Ext.Ajax.request({
url : 'someBackEndHandler',
params : {
data : Ext.encode(recordsToSend)
},
success : someSuccessFn,
failure : someFailureFn

});

kolbek
19 Jun 2009, 3:48 AM
Thanks,

In your exemple store can be a
Ext.data.JsonStore

?

19 Jun 2009, 4:03 AM
yes, JsonStore extends Store


Observable
Store
JsonStore

19 Jun 2009, 4:03 AM
btw, i updated the example, fixed a minor issue

kolbek
19 Jun 2009, 4:05 AM
Okey, thanks you.

kolbek
19 Jun 2009, 5:23 AM
I've an error on "records.data.each(function(record) {" : records.data is undefined

19 Jun 2009, 5:56 AM
are you sure that records is actually populated?

19 Jun 2009, 5:56 AM
Is there data in the store?

19 Jun 2009, 6:00 AM
Woops, try this:



var records = store.getRange();

var recordsToSend = [];

Ext.each(records, function(record) {

recordsToSend.push(record.data);
});

/*
Ext.Ajax.request({
url : 'someBackEndHandler',
params : {
data : Ext.encode(recordsToSend)
},
success : someSuccessFn,
failure : someFailureFn

});*/

i changed it to Ext.each ; )

kolbek
19 Jun 2009, 6:19 AM
This is my store :


var store = new Ext.data.JsonStore({
root: 'results',
url: 'gUsers/gUsersDatas.php',
fields: [
{name: 'ID', type: 'int'},
{name: 'ID_REF', type: 'int'},
{name: 'NAME'},
{name: 'LOGIN'},
{name: 'SUM', type: 'float'},
{name: 'MONEY'},
{name: 'COLOR'},
{name: 'ACTIVED'}
]
});

19 Jun 2009, 6:21 AM
and that's irrelevant.

kolbek
19 Jun 2009, 6:29 AM
Sorry, I'm frensh I don't understand "irrelevant"...

But with new code (with Ext.each) I don"t have error.

Thanks