PDA

View Full Version : treepanel inside a formpanel?



wallacer
8 Jun 2009, 1:29 PM
I am trying to build a simple form where a user can select a directory from a treepanel, and select a file to upload into that directory. I know my proxy is correct as I have used it elsewhere for a treepanel. When I run this code I don't even get a rootnode displayed. Is it not possible to put a treepanel inside of a formpanel?

This must be a fairly common type of upload form...



var dirTreeLoader = new Ext.tree.TreeLoader({
dataUrl:'proxy/dir_tree_json.php'
});
//set root node
var rootNode = new Ext.tree.AsyncTreeNode({
text: 'Project Folders',
id: "project_folders"
});

var uploadPanel;
function fileUpload(){
uploadPanel = new Ext.form.FormPanel({
title: 'File Upload',
fileUpload: true,
layout: 'column',
defaults:{xtype:'fieldset', layout:'form', anchor:'100%', autoHeight:true},
columnWidth: .5,
items: [{
title: "Upload Directory",
items: [{
xtype: 'treepanel',
loader: dirTreeLoader,
root: rootNode,
frame: true,
width: 200,
height: 400

}]

},{
title: "File Selection",
items: [{
xtype: 'textfield',
inputType: 'file',
fieldLabel: 'Select File',
name: 'upload_file'
},{
xtype: 'button',
text: 'Submit',
handler: uploadHandler
}]
}]

});
mainPanel.add(uploadPanel);
mainPanel.setActiveTab(uploadPanel);
}

wallacer
8 Jun 2009, 1:39 PM
Sorry for wasting anyone's time. I was trying to use the same rootNode as I was using for a different treepanel. Just had to make a new rootNode for this treepanel and it works fine :D. Ooooops

Animal
8 Jun 2009, 11:49 PM
Why did you nest your TreePanel inside another Panel?

wallacer
9 Jun 2009, 8:10 AM
the treepanel is part of a form that is contained within a tab in the center region of my viewport (mainpanel). The tab is created as a formpanel containing a treepanel (for the user to select a directory for the upload), and a form with a file input. I then attach the formpanel to the mainpanel (yes I know, another panel) as a new tab and set it to activetab.

Is there a better way to get the treepanel and form to appear under one tab in the center or my viewport than nesting panels within panels like this?

jay@moduscreate.com
9 Jun 2009, 9:03 AM
certainly. It's called treepanel for a reason. :)



uploadPanel = new Ext.form.FormPanel({
title: 'File Upload',
fileUpload: true,
layout: 'column',
defaults:{xtype:'fieldset', layout:'form', anchor:'100%', autoHeight:true},
columnWidth: .5,
items: {
title: "Upload Directory",
xtype: 'treepanel',
loader: dirTreeLoader,
root: rootNode,
frame: true
},{
title: "File Selection",
items: [{
xtype: 'textfield',
inputType: 'file',
fieldLabel: 'Select File',
name: 'upload_file'
},{
xtype: 'button',
text: 'Submit',
handler: uploadHandler
}]
}]

});

wallacer
12 Jun 2009, 4:00 PM
I still don't see a problem with nesting a treepanel inside a formpanel?

jgarcia your code just took the treepanel out of the fieldset and assigned the treepanel a title instead. Its still a treepanel inside a formpanel just the same as mine...

Why is this bad Animal?

Oh, and I understand quite clearly that treepanel is a subclass of panel, so you don't need to worry about bolding and/or underlining panel.

Thanks for the responses