Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7852859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:31:16+00:00 2026-06-02T19:31:16+00:00

In a small program that I have, I’m trying to have custom containers for

  • 0

In a small program that I have, I’m trying to have custom containers for every leaf node of my Nested List.

Here are a couple arbitrary example containers that I’m trying to test with:

Ext.define('DetailContainer1', {
    extend: 'Ext.Container',
    xtype: 'detail-container1',
    layout: {
        type: 'vbox'
    },
    height: 300,
    style: 'background-color: #a9a9a9;',
    //    flex: 1,
    items: [{
        html: 'Detail Container1'
    }]
});

Ext.define('DetailContainer2', {
    extend: 'Ext.Container',
    xtype: 'detail-container2',
    layout: {
        type: 'vbox'
    },
    height: 300,
    style: 'background-color: #c9c9c9;',
    //    flex: 1,

    items: [{
        html: 'Detail Container2',
        flex: 1
    }, {
        xtype: 'button',
        text: 'Hit me!',
        flex: 1
    }]
});

How can I switch in the new containers when the user clicks on the leaf node?

This action should happen in onLeafItemTap(). Btw the initial container (#2) isn’t showing at the moment. Is this a layout issue?

Here’s some idea of what the screen should look like:

enter image description here

enter image description here


Complete source:

Ext.Loader.setConfig({
    enabled: true
});

Ext.define('DetailContainer1', {
    extend: 'Ext.Container',
    xtype: 'detail-container1',
    layout: {
        type: 'vbox'
    },
    height: 300,
    style: 'background-color: #a9a9a9;',
    //    flex: 1,
    items: [{
        html: 'Detail Container1'
    }]
});

Ext.define('DetailContainer2', {
    extend: 'Ext.Container',
    xtype: 'detail-container2',
    layout: {
        type: 'vbox'
    },
    height: 300,
    style: 'background-color: #c9c9c9;',
    //    flex: 1,

    items: [{
        html: 'Detail Container2',
        flex: 1
    }, {
        xtype: 'button',
        text: 'Hit me!',
        flex: 1
    }]
});

Ext.define('ListItem', {
    extend: 'Ext.data.Model',
    config: {
        fields: ['text']
    }
});

Ext.define('Sencha.view.MainView', {
    extend: 'Ext.Container',
    xtype: 'mainview',
    layout: {
        type: 'hbox'
    },
    initialize: function() {
        this.treeStore = Ext.create('Ext.data.TreeStore', {
            model: 'ListItem',
            defaultRootProperty: 'items',
            root: {
                items: [{
                    text: 'Containers',
                    items: [{
                        text: 'Detail #1',
                        leaf: true
                    }, {
                        text: 'Detail #2',
                        leaf: true
                    }]
                }]
            }
        });
        this.detailContainer = Ext.create("DetailContainer2", {});

        this.nestedList = Ext.create('Ext.NestedList', {

            docked: 'left',
            width: 300,
            flex: 1,
            store: this.treeStore,

            detailCard: true,
            detailContainer: this.detailContainer,

            listeners: {
                scope: this,
                leafitemtap: this.onLeafItemTap
            }
        });

        this.setItems([this.detailContainer, this.nestedList]);
    },

    onLeafItemTap: function(nestedList, list, index, node, record, e) {
        var detailCard = nestedList.getDetailCard();
        // nestedList.setDetailContainer(Ext.create("DetailContainer1", {}))
        // detailCard.setHtml(record.get('text') + "...");
    }
});


Ext.application({

    launch: function() {
        var container = Ext.create("Ext.Container", {
            layout: {
                type: 'hbox'
            },
            items: [{
                xtype: 'mainview'
            }]
        });
        Ext.Viewport.add(container);

    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:31:17+00:00Added an answer on June 2, 2026 at 7:31 pm

    Finally I’ve figured out the proper way to solve your problem.

    Some explanations:

    • If you want to display “customized detailContainer” at the right side of your hbox, it’s quite obvious that you should disable detailCard config for your Ext.NestedList because it’s designed to display inline (i.e. take place of your Ext.NestedList).
    • When using Ext.define, everything should be included in config (except extend, xtype, alias, id, so in this case, layout has to be put in config).
    • flex should be defined in config as well.
    • At leafitemtap event, simply update your detailContainer config and remove/add it again as it would not be updated dynamically.

    Please take a look at modified code snippet below, it works perfectly for me.

    Ext.Loader.setConfig({ enabled: true });
    
    Ext.define('DetailContainer1', {
        extend: 'Ext.Container',
        xtype: 'detail-container1',
        config: {
            flex: 1,
            layout: {
                type: 'vbox'
            },
            style: 'background-color: #a9a9a9;',
            items: [
                {html: 'Detail Container1'}
            ]
        }
    });
    
    Ext.define('DetailContainer2', {
        extend: 'Ext.Container',
        xtype: 'detail-container2',
        config: {
            flex: 1,
            layout: {
                type: 'vbox'
            },
            style: 'background-color: #c9c9c9;',
    
            items: [
                {html: 'Detail Container2', flex: 1},
                {xtype: 'button', text: 'Hit me!', flex: 1}
            ]
        }
    });
    
    Ext.define('ListItem', {
        extend: 'Ext.data.Model',
        config: {
            fields: ['text']
        }
    });
    
    Ext.define('Sencha.view.MainView', {
        extend: 'Ext.Container',
        xtype: 'mainview',
        id: 'mainview',
        config: {
            layout: {
                type: 'hbox'
            },
        },
        initialize: function() {
            this.treeStore = Ext.create('Ext.data.TreeStore', {
                model: 'ListItem',
                defaultRootProperty: 'items',
                root: {
                    items: [
                        {
                            text: 'Containers',
                            items: [
                                { text: 'Detail #1', leaf: true },
                                { text: 'Detail #2', leaf: true }
                            ]
                        }
    
                    ]
                }
            });
            this.detailContainer = Ext.create("DetailContainer2");
    
            this.nestedList = Ext.create('Ext.NestedList', {
                flex: 1,
                store: this.treeStore,
                listeners: {
                    scope: this,
                    leafitemtap: this.onLeafItemTap
                }
            });
    
            this.setItems([this.nestedList, this.detailContainer]);
        },
    
        onLeafItemTap: function(nestedList, list, index, node, record, e) {
            mainview = Ext.getCmp('mainview');
            if (index==0) {
                mainview.detailContainer = Ext.create("DetailContainer1");
            } else {
                mainview.detailContainer = Ext.create("DetailContainer2");
            }
            mainview.removeAt(1);
            mainview.add(mainview.detailContainer);
    
        }
    });
    
    
    Ext.application({
        launch: function() {
            Ext.Viewport.add(
                Ext.create("Ext.Container", {
                    layout: {
                        type: 'card'
                    },
                    items: [
                        {  xtype : 'mainview'}
                    ]
                }));
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small program that I'm trying to create to get ip addresses
I have a small program that keeps updating data every second like a mentoring
I have a small program that which is confusing me. I am trying using
I have a small program that is trying to wrap an NHibernate insert into
I have a small program that uses trying to use #include <queue> . I
I have a small program that has several checkedboxlists in VS2010. I wanted to
I have a small program that's supposed to sample some value from a device
I have a small program that reads in a file and processes the data
I have a small server program that accepts connections on a TCP or local
I have a small java program that reads a file in, in eclipse i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.