Results 1 to 2 of 2

Thread: Add a tree to an Panel progamatically

  1. #1
    Sencha User
    Join Date
    Sep 2010
    Location
    Langenfeld, Germany
    Posts
    36

    Default Add a tree to an Panel progamatically

    Hi,

    i have a Problem ..

    I tried to add a tree panel to an Tab Panel ... but this dont works .. i gettng always the "undefined" Error :-(

    My Page Layout

    Page1.html
    load script1.js
    load script2.js
    load script3.js

    After loading the Page i have a button in Script1.js that should add an tree to a Panel in script2.js ...

    But this dont works .. why ?
    Error: 'accordion' is undefined

    'accordion' is my Panel ...

    Why cant i access a Panel (Script2.js) from script1.js after Page Loading !?

    Script1.js

    Code:
    fisch(tree);
    Script2.js

    Code:
    Ext.onReady(function(){
    
        Ext.QuickTips.init();
    
        //2 Spalten Layout
        var formpanel_uebersicht = new Ext.FormPanel({
            frame: true,
            items: [{
                // column layout with 2 columns
                layout:'column',
                defaults:{
                    columnWidth:0.5,
                    layout:'form',
                    border:false,
                    xtype:'panel',
                    bodyStyle:'padding:5px 5px 5px 5px'
                },
                items:[{
                    // left column
                    // defaults for fields
                    defaults:{
                        anchor:'100%'
                    },
                    items:[chart]
                },{
                    // right column
                    // defaults for fields
                    defaults:{
                        anchor:'100%'
                    },
                    items: [detailView]
                }]
            }]
        });
    
        //Accordion View
        var item1 = new Ext.Panel({
            title: 'bersicht',
            items: [formpanel_uebersicht]
        });
        var item2 = new Ext.Panel({
            title: 'Details',
            html: '<empty panel>',
            cls:'empty'
        });
        var accordion = new Ext.Panel({
            margins:'5 0 5 5',
            layout:'accordion',
            items: [item1, item2]
        });
    
    
        // Layout der Seite
        var viewpanel = new Ext.Viewport({
            layout : "border",
            items : [{
                region : "center",
                frame: true,
                title : "",
                items: [accordion]
            },{
                region : "north",
                title : "Einstellungen",
                height : 60,
                collapsible : false,
                titleCollapse : true,
                items: [formpanel]
            },{
                region : "west",
                title : "Merkmale",
                width : 250,
                collapsible : true,
                titleCollapse : true ,
                items: [tree]
            },{
                region : "east",
                title : "Geografien",
                width : 300,
                collapsible : true,
                titleCollapse : true,
                items: [tree_geo]
            }]
        });
    });
    
    var fisch = function(item){
    
        accordion.items.items[1].add(item);
    
    }

  2. #2

    Default

    You have declared the accordion variable in the nameless function used in Ext.onReady. It is not accessible outside this function.
    Quick fix:

    PHP Code:
    var accordion;

    Ext.onReady(function(){
        
    Ext.QuickTips.init();

        
    //2 Spalten Layout
        
    var formpanel_uebersicht = new Ext.FormPanel({

    ...

        var 
    item2 = new Ext.Panel({
            
    title'Details',
            
    html'<empty panel>',
            
    cls:'empty'
        
    });
        
    accordion = new Ext.Panel({
            
    margins:'5 0 5 5',
            
    layout:'accordion',
            
    items: [item1item2]
        });

    ... 
    Google 'javascript variable scope' for further information!

Similar Threads

  1. Add layers in tree panel child
    By aragonnette in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 25 Aug 2010, 2:38 AM
  2. Cannot Add Tree To Panel In Layout
    By walnutmon in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 28 Jul 2009, 10:52 AM
  3. Dynamically add another tree to the Tree Panel
    By mrkadakia in forum Ext 3.x: Help & Discussion
    Replies: 9
    Last Post: 21 Jul 2009, 8:02 AM
  4. How to add a tree panel to a viewport ?
    By murrah in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 5 Oct 2007, 10:21 PM
  5. how can I add dynamic tree to a panel?
    By realsky in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 14 Sep 2007, 10:41 AM

Posting Permissions

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