PDA

View Full Version : Help with TreeEditor logic...



DigitalSkyline
13 Jun 2007, 3:32 PM
Hello,
I would like advice on how to best use the TreeEditor class - I need to do server-side processing prior to committing an edit. I see it flowing something like this:
- select a node
- edit node text
- Ajax communication with server, server returns either true/false to allow the edit
- if true, commit the text change, else revert

However it seems that I will only be able to send the request, and the text will be changed regardless of the server response due to the Asynchronous nature of the application.

I would also like to know if its possible to trigger the editor by a means other then the default selected node-click (for ex. via a context menu).

Your assistance is much appreciated as always! :)




treeEditor = new Ext.tree.TreeEditor(stree, {
autosize : true,
ignoreNoChange : true
});
treeEditor.on("beforestartedit",
function(o,target,text){
var n = sm.getSelectedNode();
// validate some stuff to make sure a correct node is chosen
if (n.id!='exp-main' && !n.attributes.allow) {
return true;
} else {
return false;
};
}
);
treeEditor.on("beforecomplete",
function(o,newText,oldText){
if (newText.length>0) {


// make an ajax call to the server specifying the changes



} else {
msg("Oops!",'Invalid Name Specified.');
o.cancelEdit();
return false;
};
}
);

DigitalSkyline
13 Jun 2007, 11:45 PM
Well nevermind the first query, I managed to hack together a working script... however ugly it might be.

I still would like information on if it's possible to trigger the editor by a means other then the default selected node-click (for ex. via a context menu). Another example, would be dynamically adding a node, and automatically triggering the editor to force the user to enter a name for the new node. I could probably do this with a modal prompt but I'm trying to emulate the explorer interface as closely as possible. Any pointers again much appreciated.

frankel
17 Oct 2007, 11:59 PM
I guess the code may be something like this:

var ge = new xt.TreeEditor(tree, {
allowBlank:false,
blankText:'',
selectOnFocus:true
});
//...//
// The place i want to call startEdit manually type:

ge.fireEvent('startEdit',arg1, arg2);

one unkown thing is what arg1 and arg2 should be.