ExtJS Layout, Horizontally then grow vertically

给你一囗甜甜゛ 提交于 2019-12-04 08:58:58
Izhaki

What you're after is generally known as a flow layout, which ExtJS doesn't have out of the box (if you ask me, it's a bit silly they don't as it is a very common layout and in fact the one applied on most of their dataview examples, but using css rather than a layout).

But it can be achieved easily using column layout without columnWidth defined. Copying this answer:

 Ext.create('Ext.Panel', {
        width: 500,
        height: 280,
        title: "ColumnLayout Panel",
        layout: 'column',
        renderTo: document.body,
        items: [{
            xtype: 'panel',
            title: 'First Inner Panel',
            width:  250,
            height: 90
        },{
            xtype: 'panel',
            title: 'Second Inner Panel',
            width: 200,
            height: 90
        }, {
            xtype: 'panel',
            title: 'Third Inner Panel',
            width: 150,
            height: 90
        }]
  });

I found that when using the example above in ExtJS 4.2.2 the panels were stacked vertically.

I needed to add:

style: {
    float: 'left'
},

to each item and then all worked well.

I tested with both static config (like the example above) and also with dynamic add / remove (using a custom container for each child item). The container panel re-rendered in a flow-like fashion each time. Also correct when resizing the browser window - the child items moved to accommodate the new panel size.

Murray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!