PDA

View Full Version : [ treeviewdragdrop ] No Ajax on position changed while having on parents changed



Tchinkatchuk
1 Aug 2012, 9:04 AM
Hi all,

My view is composed of a Tree Panel with Tree Store defined and treeviewdragdrop also defined as a plugin.

All works fine except one thing.
I explain. When moving a node to a differents parents, the proxy url is called with new position inside so I can save the new tree and refresh the store with the new datas.
But when I only change the node positions, no ajax called is done.

The event 'itemmove' is well called but I think the plugin do not launch the call.

Do I miss something and first of all, is it possible natively with this plugin ?

Thanks in advance.



Ext.define('PIM.store.Classifications',
{
extend : 'Ext.data.TreeStore',
requires:
[
'PIM.model.Classification'
],
autoload : true,
storeId : 'ClassificationStore',
model : 'PIM.model.Classification',
autoSync : true,
proxy :
{
type : 'ajax',
url : '/api.php/classification/tree',
reader :
{
type: 'json'
},
root:
{
text : 'Classifications',
expanded : true
},
// sends single sort as multi parameter
// simpleSortMode : true,
// Parameter name to send filtering information in
// filterParam : 'query',
// The PHP script just use query=<whatever>
// encodeFilters : function(filters)
// {
// return filters[0].value;
// }
},
listeners:
{
load: function()
{
console.log('store classifications loaded');
},
beforesync: function()
{
console.log('store classifications before sync');
}
}

});




Ext.define('PIM.view.classification.Tree',
{
requires:
[
'PIM.store.Classifications'
],
extend : 'Ext.tree.Panel',
xtype : 'pim-view-classification-tree',
store : classificationsStore,
rootVisible : false,
viewConfig :
{
plugins :
{
ptype : 'treeviewdragdrop',
allowParentInserts: true,
allowContainerDrops: true
}
},
dockedItems:
[
{
xtype: 'toolbar',
dock: 'top',
items: [
{ xtype: 'pim-view-classification-trigger' }
]
}
],
listeners:
{
itemmove: function(node, oldParent, newParent, index, eOpts)
{
// console.log(node);
// console.log(oldParent);
// console.log(newParent);
// console.log(index);
// console.log(eOpts);
// Ext.MessageBox.show({
// title: 'Please wait',
// msg: 'Loading items...',
// progressText: 'Initializing...',
// width:300,
// progress:false,
// closable:true,
// });
}
}
});



Ext.define('PIM.view.classification.Panel',
{
extend : 'Ext.Panel',
xtype : 'pim-view-classification-panel',
layout :
{
type : 'vbox', // Arrange child items vertically
align : 'stretch', // Each takes up full width
},
items :
[{
xtype : 'pim-view-classification-tree',
flex : 1
}]


});

Tchinkatchuk
13 Sep 2012, 1:42 AM
Hi all,
Does anyone has a clue on this.

I forgot to print my controller method


/*** A node has been moved ***/
onItemMove: function(aNode, aOldParent, aNewParent, aIndex, aOptions)
{
Sm.log.Logger.getLogger('Controller').trace('--- CLASSIFICATION TREE --- onItemMove -> Begin');
// for ( i = 0; i < aNewParent.childNodes.length; i++ )
// {
// aNewParent.childNodes[i].data.sort = i;
// aNewParent.childNodes[i].setDirty();
// }
aNewParent.store.sync();
var notificationBox = Ext.create('PIM.utils.Notification',
{
title : __('Classification'),
html : __("Classification moved !")
});
notificationBox.show();
Sm.log.Logger.getLogger('Controller').trace('--- CLASSIFICATION TREE --- onItemMove -> End');
},


The store is launched for different level drop and not for just position drop.