首页 > Web开发 > 详细

Extjs4 似bug非bug的东西修改

时间:2014-04-11 22:05:34      阅读:818      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
/** hzm modify
     * method: Ext.panel.Table.hasLockedColumns: function(columns) {}
     * function:支持extjs grid colums三元表达式,tbar支持三元表示
        eg: user.users_type == 2 ? {text: "创建日期", flex: 1, dataIndex: ‘create_time‘} : null,
        var grid = Ext.create(‘Ext.grid.Panel‘, {
            columns: [
                new Ext.grid.RowNumberer(),
                user.users_type == 1 ? {text: "创建日期", flex: 1, dataIndex: ‘create_time‘} : null,
                {text: "备注", flex: 1, sortable: true, dataIndex: ‘remark‘}
            ]
        });
        
        user.users_type == 1 ? {
            text:‘添加会员‘,
            iconCls:‘add‘,
            handler:function() {
                MyDesktop.MemberWindow.member.addOrUpdateMember();
            }
        } : null,
        user.users_type == 1 ? ‘-‘ : null
     * note: 添加if判断column是否为空
     
    //源代码:
    if (!column.processed && column.locked) {
        return true;
    }
    */
    Ext.override(Ext.panel.Table, {
        hasLockedColumns: function(columns) {
            var i,
                len,
                column;
        
            if (Ext.isObject(columns)) {
                columns = columns.items;
            }
            for (i = 0, len = columns.length; i < len; i++) {
                column = columns[i];
                
                if (column && !column.processed && column.locked) {
                    return true;
                }
            }
        }
    });
    
    
    /**
     * hzm modify
     * method: Ext.data.Connection.onComplete : function(request, xdrResult)
     * function: gridpanel数据加载出错时(服务器内部错误),支持返回错误原因
     */
    Ext.override(Ext.data.Connection, {
        onComplete : function(request, xdrResult) {
            var me = this,
                options = request.options,
                result,
                success,
                response;
    
            try {
                result = me.parseStatus(request.xhr.status);
            } catch (e) {
                // in some browsers we can‘t access the status if the readyState is not 4, so the request has failed
                result = {
                    success : false,
                    isException : false
                };
    
            }
            success = me.isXdr ? xdrResult : result.success;
            
            if (success) {
                response = me.createResponse(request);
                me.fireEvent(‘requestcomplete‘, me, response, options);
                Ext.callback(options.success, options.scope, [response, options]);
                /**
                 * hzm modify start
                 * method: Ext.data.Connection.onComplete : function(request, xdrResult)
                 * function: gridpanel数据加载出错时(服务器内部错误),支持返回错误原因
                 * note: 原生系统,无以下段代码
                 */
                if(response && options.operation && !options.operation.response) {
                    options.operation.response = response;
                }
                /*
                 * modify end
                 */
            } else {
                if (result.isException || request.aborted || request.timedout) {
                    response = me.createException(request);
                } else {
                    response = me.createResponse(request);
                }
                me.fireEvent(‘requestexception‘, me, response, options);
                Ext.callback(options.failure, options.scope, [response, options]);
            }
            
            Ext.callback(options.callback, options.scope, [options, success, response]);
            delete me.requests[request.id];
            return response;
        }
    });
    
    
    /**
     * hzm modify
     * method: Ext.selection.Model.getSelection : function()
     * function: 当修改并reload后未更新当前grid selected range中的record
     */
    Ext.override(Ext.selection.Model, {
        getSelection: function() {
            var me = this,
                store = me.store,
                arr = this.selected.getRange();
            
            for(var i = 0; arr && i < arr.length; i++) {
                try {
                    var record = arr[i];
                    var newRecord = store.getById(record.get(record.idProperty));
                    if(newRecord) {
                        arr[i] = newRecord;
                    }
                } catch(e) {
                    alert(‘ext_override getSelection出现异常,详细信息:‘ + e);
                }
            }
            return arr;
        }
    });
bubuko.com,布布扣

 

Extjs4 似bug非bug的东西修改,布布扣,bubuko.com

Extjs4 似bug非bug的东西修改

原文:http://www.cnblogs.com/hzm112567/p/3659047.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!