PDA

View Full Version : Updating temp store from tree D&D



mckernn
26 Oct 2010, 1:43 AM
Hi,
I'm updating tree2 with items dropped from tree1.
After tree2 has a new node added, I'm trying to update a temp store to hold the values of the node dropped, so i can search through this store to upoad to server when the user has finished. The tree can be quite deep, and the user can use a filter to reload tree multiple times before actually saving any data back to the server, hence why I think it's a better idea to add the records to a temp store.

I'm only working with one item at the moment to get functionality to work.

Temp Store



var treeStdRecord = Ext.data.Record.create([
{name: 'id', mapping : 'id'}
]);


var tmpStore = new Ext.data.JsonStore({
autoLoad : false,
storeId: 'tmpStore',
record : treeStdRecord
});
Tree Panel and Loader



var grpTreeLoader = new Tree.TreeLoader({
dataUrl: 'myUrl',
preloadChildren: grpTree,
baseParams:{
param:""
}
});

var grpTreeRoot = new Ext.tree.AsyncTreeNode({
draggable: false,
id: 'src',
expanded: true,
loader: grpTreeLoader,
text: 'Groups'
});

var grpTree = new Tree.TreePanel({
margins: '0 0 0 5',
minSize: 175,
maxSize: 500,
id: 'grpTree',
split: true,
autoScroll: true,
animate: true,
enableDD: true,
border: false,
containerScroll: true,
rootVisible: false,
root : grpTreeRoot,
loader: grpTreeLoader,
ddGroup : 'treeDDGroup',
tbar:['Filter:', {
xtype:'trigger'
,triggerClass:'x-form-clear-trigger'
,onTriggerClick:function() {
this.setValue('');
}
,id:'filter'
,enableKeyEvents:true
,listeners:{
keyup:{fn:function(field, e) {
if(Ext.EventObject.ESC == e.getKey()) {
field.onTriggerClick();
}
else if(Ext.EventObject.ENTER == e.getKey()){
grpTreeLoader.baseParams.param = this.getValue()
grpTree.root.reload();
}
}
}
}
}]
});

I handle the Nodedrop and try to create a new record based on the temp store(adding node.id)
and to add to the store.



grpTree.on('nodedrop', function (e) {
var node = e.dropNode;
var newRec = new treeStdRecord(node.id);
tmpStore.add([newRec]);
});

When I get to tmpStore.add, I get an error in firefox, pointing me to ext-all,js, but I'm not sure what the error is as nothing is displayed in the console.

Is this possible.
Thanks

mckernn
26 Oct 2010, 6:16 AM
Apologies, it actually works as it is.