最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Create table like structure using Extjs - Stack Overflow

programmeradmin0浏览0评论

In Extjs 4.1.1a, I am trying to create a table like structure using containers or panels which pletely stretches horizontally and vertically to its parent ponent.

Here is the Example Fiddle

In View:

Ext.define("MyApp.view.Main", {
    extend: 'Ext.panel.Panel',       
    layout: {type: 'vbox',align:'stretch'},
    title: 'hello',
    id: 'mainContainer' 
})

In Controller:

var items = [];
for(var i=0;i<6;i++){

    var vContainer = [];
    var hContainer = [];
    for(var j=0;j<7;j++){
       hContainer.push({
         xtype: 'panel',
         flex:1,                            
       })                       
    }                       
    vContainer.push({
        xtype:'panel',
        flex: 1,
        layout: {type:'hbox',align:'stretch'},                          
        items: hContainer
    })
}

var mainController = Ext.getCmp('mainController');  //Calling the id here
mainController.add(items);  //adding the items variable which is mentioned above

I am not sure why this ain't working (not showing anything). Please assist me to solve this problem.

In Extjs 4.1.1a, I am trying to create a table like structure using containers or panels which pletely stretches horizontally and vertically to its parent ponent.

Here is the Example Fiddle

In View:

Ext.define("MyApp.view.Main", {
    extend: 'Ext.panel.Panel',       
    layout: {type: 'vbox',align:'stretch'},
    title: 'hello',
    id: 'mainContainer' 
})

In Controller:

var items = [];
for(var i=0;i<6;i++){

    var vContainer = [];
    var hContainer = [];
    for(var j=0;j<7;j++){
       hContainer.push({
         xtype: 'panel',
         flex:1,                            
       })                       
    }                       
    vContainer.push({
        xtype:'panel',
        flex: 1,
        layout: {type:'hbox',align:'stretch'},                          
        items: hContainer
    })
}

var mainController = Ext.getCmp('mainController');  //Calling the id here
mainController.add(items);  //adding the items variable which is mentioned above

I am not sure why this ain't working (not showing anything). Please assist me to solve this problem.

Share Improve this question edited Mar 15, 2013 at 10:04 Mr_Green asked Mar 15, 2013 at 9:58 Mr_GreenMr_Green 41.9k47 gold badges170 silver badges276 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Fiddle

You're pushing an array into an array and passing it as items in the main panel:

Here's the fixed code:

    var items = [];
    for(var i=0;i<6;i++){

        var vContainer; //THE PROBLEM - NO NEED FOR IT TO BE AN ARRAY
        var hContainer = [];
        for(var j=0;j<7;j++){
           hContainer.push({
             xtype: 'panel',
               title : 'H',
             flex:1,                            
           });                      
        }                       
        vContainer = {
            xtype:'panel',
            flex: 1,
            layout: {type:'hbox',align:'stretch'},
            title : 'V',
            items: hContainer
        }
        items.push(vContainer);
    }



Ext.create('Ext.panel.Panel',{
    renderTo: Ext.getBody(),
    layout: {type: 'vbox',align:'stretch'},
    title: 'hello',
    minHeight : 500,
    minWidth : 500,
    items: items        
})

Edit: Was too late, leaving the example here anyway.

You're building it wrong:

/*****************************************/
    var items = [];
    for(var i=0;i<6;i++){               

        var hContainer = [];
        for(var j=0;j<7;j++){
           hContainer.push({
             xtype: 'panel',
             flex:1
           });                  
        }                       
        items.push({
            xtype:'panel',
            flex: 1,
            layout: {type:'hbox',align:'stretch'},                          
            items: hContainer
        });
    }

/*****************************************/

Ext.create('Ext.panel.Panel',{
    renderTo: Ext.getBody(),
    layout: {type: 'vbox',align:'stretch'},
    title: 'hello',
    height: 400,
    items: items        
});

Here's the fiddle: http://jsfiddle/johanhaest/ptZp7/

发布评论

评论列表(0)

  1. 暂无评论