olivierpons
11 Apr 2012, 2:51 AM
Hi!
I've made a store this way:
var storeAttributs = Ext.create('Ext.data.Store', {
model: 'Intranet.AttributValeur',
autoLoad: true,
autoSync: true,
proxy: {
type: 'ajax',
api: {
read: 'json/attributs/',
create: 'json/item/attribut/?mode=create',
update: 'json/item/attribut/?mode=update',
destroy: 'json/item/attribut/?mode=destroy'
},
reader: {
type: 'json',
successProperty: 'success',
root: 'data',
messageProperty: 'message'
},
writer: new Ext.data.writer.Json( {
type: 'json',
writeAllFields: true,
root: 'data'
}),
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'Erreur du serveur',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
},
listeners: {
write: storeAfterWrite
}
});
And, based on the examples, I've made a grid, and a form linked to this grid.
In the form, there's a button "Save" and we the user clicks on it, here's the code:
onSave: function(){
var active = this.activeRecord,
form = this.getForm();
if (!active) {
return;
}
if (form.isValid()) {
form.updateRecord(active);
this.onReset();
}
},
Everything works fine, but there's one problem: the fields are not all sent.
I've precised "writeAllFields: true".
I've checked, the records are not phantom.
I've tried "active.save()" instead of "form.updateRecord(active)" but there's an exception raised ("Uncaught TypeError: Cannot call method 'indexOf' of undefined").
I'm stuck. Any idea where I should look to be sure to send ALL the fields (whether they're modified or not)?
I've made a store this way:
var storeAttributs = Ext.create('Ext.data.Store', {
model: 'Intranet.AttributValeur',
autoLoad: true,
autoSync: true,
proxy: {
type: 'ajax',
api: {
read: 'json/attributs/',
create: 'json/item/attribut/?mode=create',
update: 'json/item/attribut/?mode=update',
destroy: 'json/item/attribut/?mode=destroy'
},
reader: {
type: 'json',
successProperty: 'success',
root: 'data',
messageProperty: 'message'
},
writer: new Ext.data.writer.Json( {
type: 'json',
writeAllFields: true,
root: 'data'
}),
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'Erreur du serveur',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
},
listeners: {
write: storeAfterWrite
}
});
And, based on the examples, I've made a grid, and a form linked to this grid.
In the form, there's a button "Save" and we the user clicks on it, here's the code:
onSave: function(){
var active = this.activeRecord,
form = this.getForm();
if (!active) {
return;
}
if (form.isValid()) {
form.updateRecord(active);
this.onReset();
}
},
Everything works fine, but there's one problem: the fields are not all sent.
I've precised "writeAllFields: true".
I've checked, the records are not phantom.
I've tried "active.save()" instead of "form.updateRecord(active)" but there's an exception raised ("Uncaught TypeError: Cannot call method 'indexOf' of undefined").
I'm stuck. Any idea where I should look to be sure to send ALL the fields (whether they're modified or not)?