jester
21 Jun 2007, 1:23 PM
First of all I would like to say that I am very impressed by Ext and I am willing to learn some of the details but I just need a little help. Let me give you a practical example of what I am trying to do: I am trying to modify the files /examples/tree/(reorder.html & reorder.js) to talk to a database.
This is the js, pretty much unmodified except I have changed the dataUrl to coldfusion
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
var tree = new Tree.TreePanel('tree-div', {
animate:true,
loader: new Tree.TreeLoader({dataUrl:'get-nodes.cfm'}),
enableDD:true,
containerScroll: true
});
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'Website Root',
draggable:false,
id:'0'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
That works great! Now my newbie question is how to get the data back to the server when it has been modified? The two ways that I see are:
1. Have a "Save" button, that when clicked transfers the entire tree (either through an (a) AJAX request or (b) sending the user to a "save" page).
2. Initiating an AJAX "save" when the user moves a node.
So, ignoring (1) for now, what is the way to implement (2)? What is the syntax for adding an on move event handler?
So given the API reference:
on(String eventName, Function handler, [Object scope], [Object options])
I tried adding this to see what the syntax was but no dice:
function x() {
alert('Move');
}
tree.on('move', x());
Any guidance appreciated.
This is the js, pretty much unmodified except I have changed the dataUrl to coldfusion
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
var tree = new Tree.TreePanel('tree-div', {
animate:true,
loader: new Tree.TreeLoader({dataUrl:'get-nodes.cfm'}),
enableDD:true,
containerScroll: true
});
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'Website Root',
draggable:false,
id:'0'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
That works great! Now my newbie question is how to get the data back to the server when it has been modified? The two ways that I see are:
1. Have a "Save" button, that when clicked transfers the entire tree (either through an (a) AJAX request or (b) sending the user to a "save" page).
2. Initiating an AJAX "save" when the user moves a node.
So, ignoring (1) for now, what is the way to implement (2)? What is the syntax for adding an on move event handler?
So given the API reference:
on(String eventName, Function handler, [Object scope], [Object options])
I tried adding this to see what the syntax was but no dice:
function x() {
alert('Move');
}
tree.on('move', x());
Any guidance appreciated.