PDA

View Full Version : Refresh tree and delete a file with Del Key



charmont
9 Jun 2009, 6:35 AM
Hi,
When I drop a file or a directory, I am calling the php function nodedrop.php, which creates the directory and copies the file in it.
But when this is done, I would like to refresh my php page where is the call of TreeTest.init. I don't know how to do that (after the Ajax call).
I would like also that instead of dblclick, the DELETE key press is calling the remove.php function?
Thank you in advance of your help
Catherine


var TreeTest = function() {
// shorthand
var Tree = Ext.tree;

return {
init: function(param1, param2) {
//alert(param1);
// liv tree
var tree = new Tree.TreePanel({
el: 'tree',
animate: true,
autoScroll: true,
loader: new Tree.TreeLoader({
dataUrl: 'get-nodes.php',
baseParams: {
myp: param1,
myl: param2
}
}),
//enableDD:true,
enableDrag: true,
containerScroll: true,
border: false,
dropConfig: {
appendOnly: true
}
});

// add a tree sorter in folder mode
new Tree.TreeSorter(tree, {
folderSort: true
});

// set the root node
var root = new Tree.AsyncTreeNode({
text: 'Dev',
draggable: false,
// disable root node dragging
id: 'dev'
});

tree.setRootNode(root);

// render the tree
tree.render();

root.expand(false,
/*no anim*/
false);
//when dragged the node stays in first tree
//-------------------------------------------------------------
// liv tree
var tree2 = new Tree.TreePanel({
el: 'tree2',
animate: true,
autoScroll: true,
//rootVisible: false,
loader: new Ext.tree.TreeLoader({
dataUrl: 'get-nodes.php',
baseParams: {
lib: 'liv',
myp: param1,
myl: param2
}
}),
containerScroll: true,
border: false,
enableDD: true,
//enableDrop:true,
dropConfig: {
appendOnly: true
}
});

// add a tree sorter in folder mode
new Tree.TreeSorter(tree2, {
folderSort: true
});

// add the root node
var root2 = new Tree.AsyncTreeNode({
text: 'Livraison',
draggable: false,
id: 'liv'
});
tree2.setRootNode(root2);
tree2.render();

root2.expand(false,
/*no anim*/
false);
// not tested...
tree2.on("nodedrop", function(de) {
var ns = de.dropNode;
if (!Ext.isArray(ns)) {
ns = [ns];
}
var ids = [];
for (var c = 0, len = ns.length; c < len; c++) {
ids.push(ns[c].id);
}
var targetid = de.target.id;
Ext.Ajax.request({
url: 'nodedrop.php',
params: {
target: targetid,
'nodes[]': ids,
myp: param1,
myl: param2
}
});
//tree2.loader.load();
});

tree2.on("dblclick", function(n, e) {
var ids = n.id;
Ext.Ajax.request({
url: 'remove.php',
params: {
'node': ids,
myp: param1,
myl: param2
}
});
});
}
};
} ();

tryanDLS
9 Jun 2009, 7:06 AM
http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly