PDA

View Full Version : Tree reordering : update event (server call) not fired when insert after/before node



Frederes
15 Nov 2012, 1:04 AM
Hello,

I want to reorder a Tree using the 'treeviewdragdrop' plugin.
When i move the node into another (changing the parent), the update event (autoSync = true) is fired ans server URL is called.
But when i just move the node inside its parent, after or before its siblings, the server URL is not called and so i can't save the new order/index for this node.

Here my code :


var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
actionMethods: 'post',
url: 'get_or_update_nodes.php'
},
autoSync: true,
root: {
text: 'Prixorama',
id: 'root',
expanded: true
},
folderSort: true,
sorters: [{
property: 'left', // i use nested categories, this comes from server database
direction: 'ASC'
}]
});

var tree = Ext.create('Ext.tree.Panel', {
store: store,
rootVisible: true,
collapsible: true,
multiSelect: true,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
allowParentInserts: true,
appendOnly: false
},
},
renderTo: 'tree-div',
height: 500,
width: 500,
title: 'Categories',
useArrows: true,
});

How to solve this ..? Is it a bug ?

Thank you for any help !

Fred

vietits
15 Nov 2012, 2:51 AM
It's not a bug. When you reorder nodes within the same parent, only their index property is changed. Because index is not a persist property of a node so changing this property does not generate updating request. If you want to do the updating when changing the order of nodes in the same parent, you should define index as a persist property of node.


var store = Ext.create('Ext.data.TreeStore', {
fields: ['text', 'index', ...],
proxy: {
type: 'ajax',
actionMethods: 'post',
url: 'get_or_update_nodes.php'
},
autoSync: true,
root: {
text: 'Prixorama',
id: 'root',
expanded: true
},
folderSort: true,
sorters: [{
property: 'left', // i use nested categories, this comes from server database
direction: 'ASC'
}]
});