PDA

View Full Version : TreeStore autosync not firing when nodes reordered within same parent



chesstrix
3 May 2012, 8:11 PM
Hi Folks,

firstly, well done on 4.1!!! BIG improvement and much faster.

Now. I have a TreePanel that will not sync it's store when I drag and drop a node within it's parent.
It does sync if I drop the node into a new parent. It also syncs on create/edit and delete.

Could some one please take a look and see if I'm doing something stupid

My Store


Ext.define('Songle.store.Playlists', {
extend : 'Ext.data.TreeStore',
fields : ["text","id","song_id","leaf","cls"],

autoSync : true,
remoteSort : true,
folderSort : true,
nodeParam : 'pNode',
proxy : {
type : 'ajax',
api : {
create : '../songledb/s2_playlist.create_playlist',
read : '../songledb/s2_playlist.read_playlist',
update : '../songledb/s2_playlist.update_playlist',
destroy : '../songledb/s2_playlist.destroy_playlist'
},
reader : {
type : 'json',
root : 'results'
},
cacheString : 'pDC',
writer : {
type : 'json',
writeAllFields : true,
encode: true,
root :"pJson"
}
},
listeners: {
move: function( node, oldParent, newParent, index, options ) {
this.sync(); // Currently does nothing ????
}
},
root : {
text : 'Playlists',
id : '0',
expanded : true
}
});


My Tree


Ext.define('Songle.view.Playlists', {
extend : 'Ext.tree.Panel',
alias : 'widget.playlists',

store : 'Playlists',
title : 'Playlists',
rootVisible : false,
hideHeaders : true,

viewConfig : {
plugins : [{
ptype : 'treeviewdragdrop',
allowContainerDrop : true,
allowParentInsert : true,
appendOnly : false,
ddGroup : 'playlistDD'
}],
toggleOnDblClick : false
},

selType : 'cellmodel',
columns : [{
dataIndex : 'text',
editor : {
allowBlank : false,
xtype : 'textfield'
},
width : 200,
text : 'Name',
xtype : 'treecolumn'
}],

dockedItems : [{
dock : 'bottom',
xtype : 'toolbar',
baseCls : 'toolbar-white',
defaults : {
xtype : 'button',
scale : 'large',
cls : 'toolbarBtn'
},
items : ['->', {
iconCls : 'trashBtn',
id : 'playlistTrash'
}]
}],

initComponent : function() {
this.callParent();
}
});

chesstrix
16 May 2012, 5:59 PM
Bump, anyone?

chesstrix
18 May 2012, 11:40 PM
I think this is a bug.

A treePanel with autoSync: true and remoteSort:true should sync when a node is moved within the same parent. Or am I missing something????

Happy to enter a bug report if anybody else agrees.

chesstrix
21 May 2012, 2:43 PM
It's a Bug. EXTJSIV-6252 refers

Not it's not!!!!! See next reply.

Izhaki
15 Jun 2012, 3:46 AM
I have it working perfectly fine with 4.1.0;

You need to add index to you model definition:



Ext.define('BS.model.ItemCategory', {
extend: 'Ext.data.Model',
fields: [
{name: 'name' , type: 'string'},
{name: 'iconCls' , type: 'string', defaultValue: 'treenode-no-icon'},
{name: 'leaf' , type: 'boolean', defaultValue: false},
{name: 'expanded' , type: 'boolean', defaultValue: true, persist: false},
{name: 'index' , type: 'int'},
],


proxy: {
type: 'direct',

api: {
create: ItemCategories.Create,
read: ItemCategories.Read,
update: ItemCategories.Update,
destroy: ItemCategories.Delete,
},
},
});

chesstrix
17 Jun 2012, 2:41 PM
Thanks Izhaki, that has worked perfectly.

Wonder why the support team didn't advise the same :-?