PDA

View Full Version : tree management, editing problem after adding



magicfrog
3 Jul 2007, 7:49 AM
Hi

Well, after beginning with my first layout, i finally started real coding.
My first goal is to make a managed tree, with a toolbar to add / remove files and folders. The tree items are also supposed to be editables.

The "remove" button already works and the "label edition too" and so does the the "Add directory". The problem i have is that immediatly after being added, the Item is supposed to be focused to be named. The fact is that i can t get the added fields editable and i don t understand why.

If someone could gimme a clue... because i ve just no idea about what else to try :)
As i m begginning, any comments are welcomed :)

Thx,

Etienne

[HTML]

Layout = function(){
return {
init : function(){

/////// TOOLBAR ///////
var tb = new Ext.Toolbar('toolbar');
tb.add(
{text: 'Enregistrer',handler: saveTree},
{text: 'R

para
3 Jul 2007, 12:04 PM
The way I handle the naming of newly created nodes:

1) The user clicks "New Node".
2) A prompt appears asking: "Name for new node:".
3) The user types a name and clicks "Ok".
4) A node is created with the name specified.



Some of this is unique to my system, but you can get a direction from this...


addNodeConfirm: function(menu, e){
if(!vv.selectedNode || !vv.selectedTree || vv.selectedTree.isLibrary) {return;}
var newNodeType = menu.nodeType;

// If there is default text specified, use that. Otherwise prompt for input.
if(getNodeTypeConfig(newNodeType).text) {
addTreeNode(vv.selectedTree, newNodeType);
}
else {
handleCreate = function (btn, text, cBoxes){
if(btn == 'ok' && text) {
addTreeNode(vv.selectedTree, newNodeType, text);
}
}
Ext.MessageBox.show({
title:'Name',
msg: 'Name of new ' + getNodeTypeConfig(newNodeType).name + ':',
buttons: Ext.MessageBox.OKCANCEL,
prompt:true,
fn: handleCreate,
validator: validators.childName
});
}
},