PDA

View Full Version : writeAllFields property ignored



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)?

scottmartin
11 Apr 2012, 9:27 AM
Do you see all of the fields in your header? turn off autoSync for grins .. any change?

Regards,
Scott.

olivierpons
12 Apr 2012, 12:57 AM
I didn't turn off autosync, because all my components are based on autosync(), so I've given up on this problem, and I've written and "update" routine that is based merely on the fields given, with the id.

FYI I didn't find any solution.

Now I'm working on nested records, with a patch that adds all the nested records. (Question + answer in this forum).

scottmartin
12 Apr 2012, 4:27 AM
I didn't turn off autosync, because all my components are based on autosync

This may be true, but sometimes it helps in the debug process to change a behavior even you do not intend to use it.

Scott.

nicobarten
13 Apr 2012, 12:39 AM
I have the same problem, i don't use autoSync, i use store.sync().

olivierpons
13 Apr 2012, 4:41 AM
Could you add some of your code?

scottmartin
13 Apr 2012, 6:13 AM
Can I get you to verify that you have tested this in the latest 4.1 RC3?

Regards,
Scott.

olivierpons
13 Apr 2012, 6:19 AM
I've tested it on ExtJS Build date: 2012-03-13 14:31:45 (92d45716fd5f49811568ad9d756992f1cced424d)

Is it the RC3? If no, may I ask you to give me a link to the RC3?
Thank you very much!

scottmartin
13 Apr 2012, 6:28 AM
I believe you have RC1. Here is the link to RC3:
http://www.sencha.com/forum/showthread.php?194793-Ext-JS-4.1-RC3-Now-Available

Scott.

olivierpons
14 Apr 2012, 6:20 AM
Now everything seems to work, no matter the version.

I don't know which modifications made it work, but it's probably because I've made some changes, but I'm working on it 8hours/day so it's impossible to tell exactly which modifications I've made that made them work.

scottmartin
14 Apr 2012, 7:17 AM
Glad to here you got it working. I know how frustrating it can be to fix a problem and not know why .. in case it happens again. If you find the reason, please post the results.

Regards,
Scott.