转: Ext 核心 API -- Ext.getCmp

 

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>

posted on 2009-09-24 10:25  渔人码头  阅读(485)  评论(0编辑  收藏  举报

导航