when I use insertChild() or Sync(), proxy sends GET to server with just _dc param, what I should do to save my tree via proxy?
EDIT:added writer, now ext doing POST but with no data write listener also didn't call
Ext.define('App.model.FileTree',
{
extend : 'Ext.data.Model',
fields : [
{name : 'id', type: 'string'},
{name : 'name', mapping:'name', type: 'string'},
{name : 'text', type: 'string'},
]
});
Ext.define('App.store.FileTree', {
extend: 'Ext.data.TreeStore',
alias:'filestore',
model : 'App.model.FileTree',
proxy: {
actionMethods: {
create: 'POST',
destroy: 'DELETE',
read: 'GET',
update: 'POST'
},
type: 'ajax',
url : '/app/store/FileTree.php',
reader: {
type: 'json'
},
writer: {
type: 'json',
nameProperty: 'mapping'
}
},
listeners : {
write: function(store, operation, opts){
Ext.each(operation.records, function(record){
if (record.dirty) {
record.commit();
}
});
}
}
});
trying add child like:
var tree = Ext.ComponentQuery.query('filetree')[0];
var record = tree.getSelectionModel().getSelection()[0];
record.appendChild({text:'test',name:'test',id:2,leaf:true});
tree.store.sync();
Configure a writer inside the proxy. Without the writer proxy does not know what to do.
I have a tree in Ext 5.0 (but it works also in Ext 4.x) with tree model configured this way:
The tree store is configured with
autoSync:true
. Changes intext
field trigger server requests that look like this: