Results 1 to 6 of 6

Thread: treepanel inside a formpanel?

  1. #1
    Ext User
    Join Date
    May 2009
    Location
    Canada
    Posts
    21

    Default treepanel inside a formpanel?

    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...

    Code:
    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);
        }

  2. #2
    Ext User
    Join Date
    May 2009
    Location
    Canada
    Posts
    21

    Default SOLVED

    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 . Ooooops

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Why did you nest your TreePanel inside another Panel?

  4. #4
    Ext User
    Join Date
    May 2009
    Location
    Canada
    Posts
    21

    Default

    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?

  5. #5
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    certainly. It's called treepanel for a reason.

    Code:
    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
                    }]
                }]
                                                 
            });

  6. #6
    Ext User
    Join Date
    May 2009
    Location
    Canada
    Posts
    21

    Question maybe I'm missing something??

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •