Extjs4 似bug非bug的东西修改

/** 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;
        }
    });

 

Extjs4 似bug非bug的东西修改,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。