View Full Version : syn() on Ext.data.Store sending empty data in create event

Georjuan Taylor
21 May 2013, 12:43 PM
Hi guys,

I'm new with Extjs, and doing some tests, i got an error which i don't have idea what happened;

My class

fields: [
{name: 'id' , type: 'int'},
{name: 'nome' , type: 'string'},
{name: 'idade' , type: 'int'},


model: 'Funcionario',
proxy: {
type: 'ajax',

reader: {
type: 'json',
root: 'records'

writer: {
type: 'json',
root: 'records',
encode: true,
allowSingle: true,
writeAllFields: true

api: {
create: 'php/create.php',
read: 'php/read.php'


Sending create event

var funcStore = Ext.create('FuncStore');

var func = Ext.create('Funcionario',{id:4,nome:'Joaquim',idade:46});



When the sync() method is fired, it sends

records: {id:0,nome:"",idade:0}

So... it's sending empty data to create.php, somebody knows what is wrong ?

21 May 2013, 5:11 PM
The add call is incorrectly setup. It should look like:


or don't independently create the model instance and just pass the add method the model config:

funcStore.add({id:4. nome:'Joaquim', idade:46});

Georjuan Taylor
21 May 2013, 5:21 PM
Thanks chamacs, but if i do this way the .sync() doesn't work, it's do nothing; no errors, no warnings, just nothing happen, so it's that because i putted the "records" key inside in the .add(), this way the sync() work, but sending empty data

21 May 2013, 10:51 PM
after adding the record, call store.getNewRecords(). If its empty, that means the store doesnt think there are any new records which need to be sync()ed. change the id from 4 to 0 or just remove the id field from the record you are adding. This should help. This way, the store knows that its a new record.

Georjuan Taylor
22 May 2013, 2:55 AM
Thanks a lot man, this way worked!

the id=0, means it's a new record