Extjs3.1.0 版本支持17種,下面挑一些重要的簡(jiǎn)要的說明一下,要看效果,去上面給的鏈接,不再貼圖了。給Panel設(shè)置Layout的方法是一樣的,就是設(shè)置Panel的Layout配置項(xiàng)。
1. AbsoluteLayout
可以通過Panel內(nèi)部組件的決定位置來布局。通過x,y來指定。
示例用法:
代碼如下:
new Ext.Panel({
layout: 'absolute',
title: 'AbsuluteLayout',
renderTo: document.body,
frame: true,
defaultType: 'textfield',
width: 400,
height:250,
items: [{
x: 0, y: 5,
xtype: 'label',
text: 'Send To:'
},
{
x: 60, y: 0,
name: 'to'
}, {
x: 0, y: 35,
xtype: 'label',
text: 'Subject:'
}, {
x: 60, y: 30,
name: 'subject'
},
{
x: 0, y: 60,
xtype: 'textarea',
name: 'msg'
}]
});
2.AccordionLayout
Accordion的意思是手風(fēng)琴,顧名思義,這種布局可以向手風(fēng)琴那樣,有的組件張開,有的閉合。這種效果作為側(cè)邊欄比較有用。
示例用法:
代碼如下:
new Ext.Panel({
title: 'Accordion Layout',
layout: 'accordion',
renderTo: document.body,
defaults: { // applied to each contained panel
bodyStyle: 'padding:15px'
},
layoutConfig: {
// layout-specific configs go here
titleCollapse: true,
animate: true,
activeOnTop: false
},
items: [{
title: 'Panel 1',
html: '<p>Panel content!</p>'
}, {
title: 'Panel 2',
html: '<p>Panel content!</p>'
}, {
title: 'Panel 3',
html: '<p>Panel content!</p>'
}]
});
});
3. AnchorLayout
這種Layout非常有用,尤其是在布局含有GridView這一類控件的頁面的時(shí)候,AnchorLayout實(shí)際上類似于Winform的form默認(rèn)的布局方式,不過它僅僅可以固定某一個(gè)組件距離頁面邊框(右邊框和底邊框)的距離(絕對(duì)的像素或者相對(duì)比例)。 通過anchor屬性設(shè)置,anchor屬性的設(shè)置API文檔上解釋的十分清楚,就直接摘抄過來了:
anchor : String
This configuation option is to be applied to child items of a container managed by this layout (ie. configured withlayout:'anchor').
This value is what tells the layout how an item should be anchored to the container. items added to an AnchorLayout accept an anchoring-specific config property of anchor which is a string containing two values: the horizontal anchor value and the vertical anchor value (for example, '100% 50%'). The following types of anchor values are supported:
Percentage : Any value between 1 and 100, expressed as a percentage.
The first anchor is the percentage width that the item should take up within the container, and the second is the percentage height. For example:
// two values specified
anchor: '100% 50%' // render item complete width of the container and
// 1/2 height of the container
// one value specified
新聞熱點(diǎn)
疑難解答
圖片精選