Package: | Ext |
Class: | TabPanel |
Extends: | Observable |
Defined In: | TabPanel.js |
// basic tabs 1, built from existing content
var tabs = new Ext.TabPanel("tabs1");
tabs.addTab("script", "View Script");
tabs.addTab("markup", "View Markup");
tabs.activate("script");
// more advanced tabs, built from javascript
var jtabs = new Ext.TabPanel("jtabs");
jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
// set up the UpdateManager
var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
var updater = tab2.getUpdateManager();
updater.setDefaultUrl("ajax1.htm");
tab2.on('activate', updater.refresh, updater, true);
// Use setUrl for Ajax loading
var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
tab3.setUrl("ajax2.htm", null, true);
// Disabled tab
var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can"t see me cause I"m disabled");
tab4.disable();
jtabs.activate("jtabs-1");
}
属性 | 定义对象 | |
---|---|---|
bodyEl : Ext.Element | TabPanel | |
The body element that contains TabPaneItem bodies. | ||
el : Ext.Element | TabPanel | |
The container element for this TabPanel. | ||
maxTabWidth : Number | TabPanel | |
The maximum width of a tab (ignored if resizeTabs is not true). | ||
minTabWidth : Number | TabPanel | |
The minimum width of a tab (ignored if resizeTabs is not true). | ||
monitorResize : Boolean | TabPanel | |
Set this to true to turn on window resizing monitoring (ignored if resizeTabs is not true). | ||
preferredTabWidth : Number | TabPanel | |
The preferred (default) width of a tab (ignored if resizeTabs is not true). | ||
resizeTabs : Boolean | TabPanel | |
Set this to true to enable dynamic tab resizing. | ||
tabPosition : String | TabPanel | |
The position of the tabs. Can be "top" or "bottom" |
方法 | 定义对象 | |
---|---|---|
TabPanel(String/HTMLElement/Element container , Boolean config ) |
TabPanel | |
Create new TabPanel. | ||
activate(String/Number id ) : void |
TabPanel | |
Activate a TabPanelItem. The currently active will be deactivated. | ||
addEvents(Object object ) : void |
Observable | |
将对象中没有的事件从给出的对象中复制过来。 | ||
addListener(String eventName , Function handler , [Object scope ], [Object options ]) : void |
Observable | |
为该组件加入事件处理器函数 | ||
addTab(String id , String text , [String content ], [Boolean closable ]) : Ext.TabPanelItem |
TabPanel | |
Creates a new TabPanelItem by looking for an existing element with the provided id - if it's not found it creates one. | ||
addTabItem(Ext.TabPanelItem item ) : void |
TabPanel | |
Add an existing TabPanelItem. | ||
autoSizeTabs() : void | TabPanel | |
Manual call to resize the tabs (if resizeTabs is false this does nothing) | ||
beginUpdate() : void | TabPanel | |
Disables tab resizing while tabs are being added (if resizeTabs is false this does nothing) | ||
destroy([Boolean removeEl ]) : void |
TabPanel | |
Destroys this TabPanel | ||
disableTab(String/Number id ) : void |
TabPanel | |
Disable a TabPanelItem. It cannot be the active tab, if it is this call is ignored.. | ||
enableTab(String/Number id ) : void |
TabPanel | |
Enable a TabPanelItem that is disabled. | ||
endUpdate() : void | TabPanel | |
Stops an update and resizes the tabs (if resizeTabs is false this does nothing) | ||
fireEvent(String eventName , Object... args ) : Boolean |
Observable | |
触发指定的事件, 并将参数传入(至少要有事件名称)。 | ||
getActiveTab() : Ext.TabPanelItem | TabPanel | |
Get the active TabPanelItem | ||
getCount() : Number | TabPanel | |
Returns the number of tabs | ||
getTab(String/Number id ) : Ext.TabPanelItem |
TabPanel | |
Returns the TabPanelItem with the specified id/index | ||
hasListener(String eventName ) : Boolean |
Observable | |
检查该对象是否拥有指定事件的侦听器 | ||
hideTab(String/Number id ) : void |
TabPanel | |
Hides the TabPanelItem with the specified id/index | ||
on(String eventName , Function handler , [Object options ]) : void |
Observable | |
为该组件加入事件处理器函数, addListener 的简写方式 | ||
purgeListeners() : void | Observable | |
从对象身上移除所有的侦听器 | ||
removeListener(String eventName , Function handler , [Object scope ]) : void |
Observable | |
移除侦听器 | ||
removeTab(String/Number id ) : void |
TabPanel | |
Remove a TabPanelItem. | ||
setTabWidth(Number The ) : void |
TabPanel | |
Resizes all the tabs to the passed width | ||
syncHeight([Number targetHeight ]) : void |
TabPanel | |
Updates the tab body element to fit the height of the container element for overflow scrolling | ||
un(String eventName , Function handler , [Object scope ]) : void |
Observable | |
移除侦听器, removeListener 的简写方式 | ||
unhideTab(String/Number id ) : void |
TabPanel | |
"Unhides" the TabPanelItem with the specified id/index |
事件 | 定义对象 | |
---|---|---|
beforetabchange : (Ext.TabPanel this , Object e , Ext.TabPanelItem tab ) |
TabPanel | |
Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change | ||
tabchange : (Ext.TabPanel this , Ext.TabPanelItem activePanel ) |
TabPanel | |
Fires when the active tab changes |
public Ext.Element bodyEl
public Ext.Element el
public Number maxTabWidth
public Number minTabWidth
public Boolean monitorResize
public Number preferredTabWidth
public Boolean resizeTabs
public String tabPosition
public function TabPanel(String/HTMLElement/Element container
, Boolean config
)
container
: String/HTMLElement/Elementconfig
: Booleanpublic function activate(String/Number id
)
id
: String/Numbervoid
public function addEvents(Object object
)
object
: Objectvoid
public function addListener(String eventName
, Function handler
, [Object scope
], [Object options
])
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Object
组合选项
使用选项参数可以组合不同类型的监听器:
下面是一个标准的、延迟执行的、一次性的监听器,将会自动停止事件并传递一个自定义的参数(forumId)
el.on('click', this.onClick, this, { single: true, delay: 100, stopEvent : true, forumId: 4 });
这个方法也允许传递的单个参数是一个包含多个指定处理函数的设置对象。
一次调用多个处理函数
代码:
el.on({ 'click' : { fn: this.onClick scope: this, delay: 100 }, 'mouseover' : { fn: this.onMouseOver scope: this }, 'mouseout' : { fn: this.onMouseOut scope: this } });
或者简写为:
代码:
el.on({ 'click' : this.onClick, 'mouseover' : this.onMouseOver, 'mouseout' : this.onMouseOut scope: this });
void
public function addTab(String id
, String text
, [String content
], [Boolean closable
])
id
: Stringtext
: Stringcontent
: Stringclosable
: BooleanExt.TabPanelItem
public function addTabItem(Ext.TabPanelItem item
)
item
: Ext.TabPanelItemvoid
public function autoSizeTabs()
void
public function beginUpdate()
void
public function destroy([Boolean removeEl
])
removeEl
: Booleanvoid
public function disableTab(String/Number id
)
id
: String/Numbervoid
public function enableTab(String/Number id
)
id
: String/Numbervoid
public function endUpdate()
void
public function fireEvent(String eventName
, Object... args
)
eventName
: Stringargs
: Object...Boolean
public function getActiveTab()
Ext.TabPanelItem
public function getCount()
Number
public function getTab(String/Number id
)
id
: String/NumberExt.TabPanelItem
public function hasListener(String eventName
)
eventName
: StringBoolean
public function hideTab(String/Number id
)
id
: String/Numbervoid
public function on(String eventName
, Function handler
, [Object options
])
eventName
: Stringhandler
: Functionoptions
: Objectvoid
public function purgeListeners()
void
public function removeListener(String eventName
, Function handler
, [Object scope
])
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function removeTab(String/Number id
)
id
: String/Numbervoid
public function setTabWidth(Number The
)
The
: Numbervoid
public function syncHeight([Number targetHeight
])
targetHeight
: Numbervoid
public function un(String eventName
, Function handler
, [Object scope
])
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function unhideTab(String/Number id
)
id
: String/Numbervoid
public event beforetabchange
this
: Ext.TabPanele
: Objecttab
: Ext.TabPanelItempublic event tabchange
this
: Ext.TabPanelactivePanel
: Ext.TabPanelItem