getCmp( String id ) : Component
通过id得到一个Component对象
<script type="text/javascript">
function InitDialog() {
// 生名组件
new Ext.Panel({
renderTo:"hello-dialog",
id:"hello-dialog",
title:"面板头部header",
width:300,
height:200,
html:'<h1>面板主区域</h1>',
tbar:[{text:'顶部工具栏topToolbar'}],
bbar:[{text:'底部工具栏bottomToolbar'}],
buttons:[{text:"按钮位于footer"}]
});
}
function Show() {
var dialog = Ext.getCmp("hello-dialog"); // 根据ID获取组件
dialog.show(); // 得到组件后,就可以对他想干什么就干什么了
}
function Hide() {
var dialog = Ext.getCmp("hello-dialog");
dialog.hide();
}
Ext.onReady(InitDialog);
</script>
<button onclick="Hide();">Hidde</button>
<button onclick="Show();">Show</button>
<div id="hello-dialog">
</div>
本文介绍了如何通过 Ext.getCmp 方法根据组件的 id 获取 Component 对象。通过这个方法,可以方便地对组件进行显示、隐藏等操作。示例中展示了创建一个包含头部、工具栏和按钮的面板,并通过 Ext.getCmp 方法展示和隐藏该面板。
1056

被折叠的 条评论
为什么被折叠?



