简析 Ext.LoadMask

girdpanel 时如果指定了 loadmask 那么在 load 数据时会自动出现一个层遮盖,很酷,但看  gridpanel 的源码 ,丝毫找不到关于 loadmask 运动的一丝痕迹 ,而仅仅只有一段

 

this.loadMask = new Ext.LoadMask(this.bwrap,
Ext.apply({store:store}, this.initialConfig.loadMask));

 

bwrap 在父类 panel 中定义 ,正是遮盖层所在的位置


Class Ext.LoadMask


A simple utility class for generically masking elements while loading data. If the store config option is specified, the masking will be automatically synchronized with the store's loading process


则负责起了与 store 的协作 ,store 只需把它交给 loadmask  ,而自己不用显式调用 loadmask 的 show hide


于是在 loadmask 中便处理了 store的各种事件

 

this.store.on('beforeload', this.onBeforeLoad, this);
this.store.on('load', this.onLoad, this);
this.store.on('loadexception', this.onLoad, this);

 

从而  与 store  解耦 , store 的 load 函数 分析:

 

load: function(options) {
    options = options || {};
    //通知 loadmask 显示
    if (this.fireEvent("beforeload", this, options) !== false) {
        this.storeOptions(options);
        var p = Ext.apply(options.params || {},
        this.baseParams);
        if (this.sortInfo && this.remoteSort) {
            var pn = this.paramNames;
            p[pn["sort"]] = this.sortInfo.field;
            p[pn["dir"]] = this.sortInfo.direction;
        }
        //这个函数里 应该 结束后
        //fireEvent load 通知 loadmask 隐藏
        this.proxy.load(p, this.reader, this.loadRecords, this, options);
        return true;
    } else {
        return false;
    }
}
 

则正是调用了 loadmask ,由于基于 事件 ,当然我们也可以自由的添加 handler 到 beforeload .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值