zoukankan      html  css  js  c++  java
  • 『ExtJS』01 008. ExtJS 4 组件扩展

    本文将介绍如何使用你自己的component扩展ExtJS内建的component。

    如何去做


    在这里,我们将创建一个Ext.panel.Panel的扩展组件。

    Language: JavaScript

    Framework: ExtJS 4.1.1a

    IDE: Excplise J2EE + Spket

    1. 定义一个Ext.panel.Panel的子类

         1: Ext.define('Cookbook.DispalyPanel',{ extend:'Ext.panel.Panel' });
    2. 重载Ext.panel.Panel的initComponent方法,并调用父类的initComponent方法

         1: Ext.define('Cookbook.DispalyPanel',{ extend:'Ext.panel.Panel',
         2:  
         3: initComponent:function(){
         4:     // call the extended class' initomponent method
         5:     this.callParent(arguments);
         6: }
         7:  
         8: });
         9:  
    3. 添加你自己的配置信息到initComponent方法中

         1: Ext.define('Cookbook.DispalyPanel',{ extend:'Ext.panel.Panel',
         2:  
         3: initComponent:function(){
         4:     // apply our configuration to the class
         5:     Ext.apply(this,{
         6:        title:'Display Panel',
         7:        html:'Display some information here!',
         8:        200,
         9:        height:200,
        10:        renderTo:Ext.getBody()
        11:     });
        12:  
        13:     // call the extended class' initComponent method
        14:     this.callParent(arguments);
        15: }
        16:  
        17: });
        18:  
    4. 创建这个子类的实例

         1: var displayPanel = Ext.create('Cookbook.DisplayPanel'); displayPanel.show();

    说明


    1. 使用extend配置项告诉框架,我们要新建一个Ext.panel.Panel组件的子类;

    2. 我们先在initComponent中添加我们自己的动作,最后使用callParent来调用父类的方法,以保证程序的顺利运行;

    3. 使用Ext.apply方法来使我们的配置项生效。






    版权声明:

    作者:莫不逢
    出处:http://www.cnblogs.com/sitemanager/
    Github:https://github.com/congjf

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。


  • 相关阅读:
    FMDB的简单使用
    SQLite3的基本使用
    KVC与KVO的实现原理
    数据存储与IO(二)
    数据存储与IO(一)
    cocoapods卸载与安装的各种坑
    Core Data的一些常见用法
    UITextField限制中英文字数和光标定位以及第三方输入限制问题
    prompt-tuning paper reading
    ACL2021 事件抽取相关论文阅读
  • 原文地址:https://www.cnblogs.com/sitemanager/p/2794371.html
Copyright © 2011-2022 走看看