Here is my model:
Ext.define('A.model.Group', {
extend: 'Ext.data.Model',
fields:['id', 'name'],
proxy: {
type: 'rest',
url: '/group',
reader: {
type: 'json',
root: 'data'
},
writer: {
type: 'json',
writeAllFields: false
}
}
});
The model is being used in a Tree via a TreeStore
The problem is that when a PUT, POST or DELETE method is done, instead of sending only fields from the model in the JSON payload, fields from Ext.data.NodeInterface are also sent. Here is an example payload:
{"id":"","name":"TestGroup","parentId":"8","index":0,"depth":3,"checked":null}
I don’t want the extra fields parentId, index, depth, and checked to be sent. What is the best way to do this? I don’t want to have to ignore them on the server.
If you wan’t to send only specific data to server, writeAllFields is not the solution as if is set to false it only sends the modified fields.
The solution for your problem is defining your own writer and overriding the method
getRecordDatahere is a posible example: