2 qq 29271533 qq_29271533 于 2017.01.13 11:31 提问

exjts listeners事件combo无响应 30C

extjs 中引用lispanel.js 其中formconfig中的combo的listeners的监听事件无响应,其他的render中on事件都 有响应:下面是代码grid = Ext.create('Ext.frf.list.ListPanel',{
id : 'domainGrid',
title:'岗点路段管理',
entityName : 'gangdian',
singlePanel:true ,
border:true,
region : 'center',
tbConfig : {mode : 'normal'},
bbConfig : {mode : 'normal'},
searchConfig:{
'bmmc': {xtype: 'combo',fieldLabel:'所属大队',data:bm,emptyText: '请选择大队',listeners:{
select:function(combo,record,index){//此处有效果
Ext.getCmp('domainGrid_search_gangdian_ksmc').setValue('');
addKsbh(Ext.getCmp('domainGrid_search_gangdian_bmmc').getValue());
}
}},

                },

                createConfig : {
                   url : '${basePath}gangdian_add.action',
                   autoLoad : true 
                },

                formConfig: {
                    'bmmc':{ xtype: 'combo',fieldLabel:'所属大队',data:bm,emptyText: '请选择大队',selectOnFocus:true,listeners:{
                      select:function(combo,record,index){
                        alert('11');//此处事件不起作用
                       console.log('222');
                       }

                    }},

                    'xy':   { xtype: 'textfield',fieldLabel:'范围',fieldName:'xy', listeners:{
                                render:function(v,record){

                                v.getEl().on('click',function(v){

                                 alert('aaa');//此处有效果

                                    });
                                    }
                                }},

                    'bz':{ xtype: 'textfield',fieldLabel:'描述',fieldName:'bz'},
                    'UUID':{ xtype: 'textfield',fieldLabel:'UUID',fieldName:'UUID',hidden: true}
                },
                properties : [

                    {name : 'xy',text : '坐标',width : 220,align : 'left',    renderer:function(v, metaData, record, rowIndex, colIndex, store, view){
                        if(v!=null||metaData!=null){
                        var str = "<a href='#' onclick=function1('"+v+"');>"+v+"</a>";
                       return str;
                    }
                }},
                    {name : 'UUID',text : 'UUID',width:150 ,align :'left',hidden: true}

                ]
            });

4个回答

showbo
showbo   Ds   Rxr 2017.01.13 14:53

Ext.frf.list.ListPanel是自己写的插件吧,原生extjs没有这个插件,自己看下api说明或者源代码

qq_29271533
qq_29271533   2017.01.13 15:17

你QQ多少,我发你listpanel看看,

qq_29271533
qq_29271533   2017.01.13 15:22

/**

  • @class Ext.frf.list.ListPanel 列表面板,内置表格和图标两种视图,并提供基本CRUD的功能。
  • @extends Ext.panel.Panel
  • @author Kivian Chen
  • @date Jul.2014
  • @version 1.0 */

Ext.define('Ext.frf.list.ListPanel', {
extend : 'Ext.panel.Panel',
alias : 'widget.frfListPanel',
alternateClassName : ['Ext.frf.ListPanel'],

// 缺省设置
border : false,
bodyBorder : true,
defaultViewConfig: {
    border: false,
    loadMask: true,
    overflowY: 'scroll',
    padding: '5px 0px 0px 0px'
},
defaultGridConfig: {
    border: false,
    columnLines: true,
    enableLocking: false,
    loadMask: true,
    rowNumber: true,
    columnMenuDisabled: true,
    /***************************add gridviewdragdrop plugin     modified by song.hl at 2014-12-24   begin***************************/
    getItemSelector : function(){
        return this.view.itemSelector;
    },
    getRecord: function(node) {
        node = this.view.getNode(node);
        if (node) {
            var recordIndex = node.getAttribute('data-recordIndex');
            if (recordIndex) {
                recordIndex = parseInt(recordIndex, 10);
                if (recordIndex > -1) {
                    return this.store.data.getAt(recordIndex);
                }
            }
            return this.dataSource.data.get(node.getAttribute('data-recordId'));
        }
    }
    /***************************modified by song.hl at 2014-12-24   end***************************/
},

/**
 * @cfg {String} defaultView 缺省的视图类型,可以是grid/view,缺省为grid
 * @type String
 *  - grid : 缺省显示Grid视图,缺省值
 *  - view : 缺省显示Views视图
 */
defaultView : 'grid',
/**
 * @cfg {Boolean} singlePanel 是否只初始化一种视图
 * @type Boolean
 *  - true : 只初始化一种视图,此时defaultView的设置为初始化的视图的类型
 *  - false : 初始化表格和图标两种视图,缺省显示的视图为defaultView配置,工具栏设置视图切换按钮,缺省值 
 */
singlePanel : false,

/**
 * @cfg {String} entityName 可选,对应/操作的实体类名,缺省为‘ClassInfo’
 */
entityName : 'ClassInfo',
/**
 * @cfg {Boolean} multiSelect 可选,是否允许多选
 * @type String
 *  - true : 允许多选,缺省
 *  - false : 单选
 */
multiSelect: true,
/**
 * @cfg {Object} createConfig 可选,表格数据新建配置;配置后将会在工具栏上创建“新建”按钮。
 * 
 * @param {String} mode 必须;
 *      “新建”窗口的模式: 
 *      - 'iframe': 窗口为iframe(这种情况下必须设置url);
 *      - 'formPanel': 窗口为根据fieldConfig创建的formPanel。
 *      缺省值: 'formPanel'
 * @param {String} title 可选;
 *      “新建”窗口/FormPanel的标题;
 *      缺省值: 'Form for Create'
 * @param {String} url 必须;
 *      - 当“新建”窗口的模式为'iframe'时,加载的iframe的url;
 *      - 当“新建”窗口的模式为'formPanel'时,Create动作的Action Url;
 * @param {Numeric} width 可选;
 *      窗口的宽度,单位为px;
 *      缺省值: 800
 * @param {Numeric} height 可选;
 *      窗口的高度,单位为px;
 *      缺省值: 600
 * @param {String} iconCls 可选;
 *      窗口的Icon样式;
 *      缺省值: 'modal'
 */
/**
 * @cfg {Object} modifyConfig 可选,表格数据编辑配置;配置后将会在工具栏上创建“修改”按钮。
 * 
 * @param {String} mode 必须;
 *      “编辑”窗口的模式:
 *      - 'iframe': 窗口为iframe(这种情况下必须设置url);
 *      - 'formPanel': 窗口为根据fieldConfig创建的formPanel。
 *      缺省值: 'formPanel'
 * @param {String} title 可选;
 *      “编辑”窗口的标题;
 *      缺省值: 'Form for Modify'
 * @param {String} url 必须;
 *      - 当“编辑”窗口的模式为'iframe'时,加载的iframe的url。
 *      - 当“编辑”窗口的模式为'formPanel'时,Modify动作的Action Url。
 * @param {Numeric} width 可选;
 *      窗口的宽度,单位为px;
 *      缺省值: 800
 * @param {Numeric} height 可选;
 *      窗口的高度,单位为px;
 *      缺省值: 600
 * @param {String} iconCls 可选;
 *      窗口的Icon样式;
 *      缺省值: 'modal'
 * @param {Object/Boolean} selectedCheck 可选
 *      监听选择的状态——将按钮disable:未选取任何记录;将按钮enable:选中任意记录,并符合设定的条件。
 *      - 当值为布尔型时,按钮的enable与否根据是否仅选中单条记录;
 *      - 是否需要自己控制按钮   是:flag:true
 *      - 若设定条件,参数必须为一个Object - selectedCheck:{enableMulti: true, flag:true,condition: {status: 1}};
 *      缺省值: true
 * @param {Object} paramConfig 可选;
 *      当“编辑”窗口的模式为'iframe'时,传递的参数的配置。key为需要传递的参数的名字,value为传递的参数对应的取值的字段名(可以为多个,分号分隔)。
 *      缺省值: {'uuid':'UUID'}
 */
/**
 * @cfg {Object} removeConfig 可选,表格数据删除配置;配置后将会在工具栏上创建“删除”按钮。
 * 
 * @param {String} msg 可选;
 *      删除前Confirm的提示信息。
 *      缺省值: 'Are you sure to remove these ?'
 * @param {String} url 必须;
 *      删除动作的url。
 * @param {Object} keyField 可选;
 *      keyField为传递的参数对应的取值的字段名,单个字段。
 *      缺省值: {this.entityName + '._.ids':'UUID'}
 * @param {Object/Boolean} selectedCheck 可选
 *      监听选择的状态——将按钮disable:未选取任何记录;将按钮enable:选中任意记录。
 *      - 当值为布尔型时,按钮的enable与否根据是否仅选中单条记录;
 *      - 是否需要自己控制按钮   是:flag:true
 *      - 当需要在多条选中的情况下,按钮依然处于enable状态,参数必须为一个Object,例如,selectedCheck:{enableMulti: true, flag:true};
 *      缺省值: true
 */
/**
 * @cfg {Object} tbConfig 可选,工具栏配置;配置后将会在GridPanel周边(除底部)创建工具栏。
 * 
 * @param {String} mode 可选;
 *      有三种模式:'normal'、'concat'、'replace':
 *      - 'normal': 创建增、删、改按钮;
 *      - 'concat': 创建增、删、改按钮之外还根据注入的配置创建新的按钮;
 *      - 'replace': 不创建增、删、改按钮,但是使用注入的配置创建按钮。
 *      在缺省状态下,增、删、改的按钮会靠左对齐,这三个按钮是否创建还根据是否注入了增、删、改的配置来决定。
 *      缺省值: 'normal'
 * @param {String} position 可选;
 *      允许的值为:'top' — 顶部,'left' — 左边,'right' — 右边
 *      缺省值: 'top'
 * @param {String} items 可选;
 *      需要新增加的/或者自定义(replace)按钮的配置(Ext.button.Button);
 *      当mode为'concat'和'replace'时必需。
 *      缺省值: 无
 *      每个item可选参数:selectedCheck。
 *      监听选择的状态——将按钮disable:未选取任何记录;将按钮enable:选中任意记录。
 *      - 当值为布尔型时,按钮的enable与否根据是否仅选中单条记录;
 *      - 当需要在多条选中的情况下,按钮依然处于enable状态,参数必须为一个Object;例如,selectedCheck:{enableMulti: true},缺省enableMulti为false;
 *      缺省值: true
 * @param {String} align 可选;
 *      当模式为'concat'时,设定新增的按钮的位置:
 *      - 'left': 工具栏的最左边,
 *      - 'follow': 跟随在增、删、改按钮右边,
 *      - 'right': 工具栏的最右边。
 *      缺省值: 'follow'
 */
/**
 * @cfg {Object} bbConfig 可选,底部工具栏配置;配置后将会在Grid的底部创建工具栏。
 * 
 * @param {String} mode 可选;
 *      有两种模式:'normal'、'replace':
 *      - 'normal': 使用缺省分页工具栏,
 *      - 'replace': 使用传入配置创建工具栏,
 *      缺省值: 'normal'
 * @param {String} config 可选;
 *      当模式为'replace'时,使用该配置创建分页栏。
 * @param {Boolean} displayInfo 可选;
 *      是否显示分页栏右边的条码数量和分页数量等信息,当模式为'replace'时无效;
 *      缺省值: true - 显示信息      
 */
/**
 * @cfg {Object} storeConfig 必须,本控件使用的Store配置。
 * 
 * @param {String} mode 可选;
 *      有两种模式:'normal', 'custom'
 *      - 'normal': 未自定义Store,该选项将传入配置和缺省配置合并。
 *      - 'custom': 完全使用自定义的Store配置。
 *      缺省值: 'normal'
 * @param {Object} config 可选,模式为'custom'时必须;
 *      标准Ext.data.Store的配置。
 * @param {Boolean} autoLoad 可选
 *      是否自动加载数据。
 *      缺省值: true
 * @param {Object} proxy 可选,需要使用的Ext.data.proxy.Proxy的配置
 *      需要使用的proxy的配置,缺省使用Ajax类型(仅需配置url参数即可);非Ajax类型需要传入完整配置。
 * @param {String} url 可选,当使用Ajax类型proxy时需要配置
 *      当使用Ajax类型proxy时,因是缺省配置,因此允许仅传入url即可。
 *      proxy和url参数,两种可以选择其一配置即可,选择url则使用默认Ajax类型proxy。
 */
/**
 * @event beforecreate(this)
 *  弹出创建窗口前触发
 */
/**
 * @event aftercreate(options, this)
 *  关闭创建窗口前触发
 */
/**
 * @event beforemodify(this)
 *  弹出编辑窗口前触发
 */
/**
 * @event aftermodify(options, this)
 *  关闭编辑窗口前触发
 */
/**
 * @event beforeremove(this)
 *  删除动作发生前触发
 */
/**
 * @event afterremove(options, this)
 *  删除动作完成后触发
 */
/**
 * @event load(store, records, successful)
 *  数据加载后触发
 */
/**
 * @event beforedeselect(this, record)
 *  记录反选前触发
 */
/**
 * @event beforeselect(this, record)
 *  记录选中前触发
 */
/**
 * @event beforeitemclick(this, record, index)
 */
/**
 * @event beforeitemdblclick(this, record, index)
 */
/**
 * @event itemclick(this, record, index)
 */
/**
 * @event itemdblclick(this, record, index)
 */
/**
 * @event select(this, record)
 *  选中动作后触发
 */
/**
 * @event deselect(this, record)
 */
/**
 * @event selectionchange(this, selected)
 *  选中集合被改变后出发
 */

// 缺省分页参数
pagerParam : {'pageSize': 25, 'pageNo': 1},
// private
// 采用border布局,不可变更!
layout : 'border',

beforeComponentInit : function() {
    // 如果设定了公共级别分页参数,使用公用分页参数
    if (typeof globalVar !== 'undefined') {
        if (typeof globalVar.pager !== 'undefined') {
            Ext.apply(this.pagerParam, globalVar.pager);
        }
    }

    this.initDataModel();
    this.initStore();
    this.initToolBar();
    this.initPagerBar();

    if (!this.singlePanel || (this.singlePanel && this.defaultView === 'grid')) {
        if (typeof this.gridConfig !== 'undefined') {
            Ext.applyIf(this.gridConfig, this.defaultGridConfig);
        } else {
            this.gridConfig = Ext.clone(this.defaultGridConfig);
        }
        if (this.gridConfig.rowNumber) {
            this.columns.unshift({xtype: 'rownumberer', locked: this.gridConfig.enableLocking, width: 30, align: 'center'});
        }
        this.initSelectionModel();
        this.initColumnModel();
        this.initGrid();
    }

    if (!this.singlePanel || (this.singlePanel && this.defaultView === 'view')) {
        if (typeof this.viewConfig !== 'undefined') {
            Ext.applyIf(this.viewConfig, this.defaultViewConfig);
        } else {
            this.viewConfig = Ext.clone(this.defaultViewConfig);
        }
        this.initView();
    }
    this.initList();
    if (typeof this.searchConfig !== 'undefined') {
        this.initSearchFrom();
    }
},

initComponent : function() {
    var me = this;
    // private
    // 根据选择的记录数量或者条件决定按钮的状态,该参数保持需要联动的按钮Id
    me.btnBeChecked = [];
    me.searchElements = [];
    me.formElements = [];
    // formPanel Status(current mode : create or modify)
    me.currentFormMode = [];
    // ajax action(create, modify, remove)
    me.currentAjaxAction = [];
    me.items = [];

    me.beforeComponentInit();
    me.callParent();
    me.on('render', this.checkBtnPermission, me);
},

initDataModel : function() {
    if (typeof this.fields === 'undefined' && typeof this.properties === 'undefined') {
        alert('需要定义实体属性结构(定义properties),或者定义fields和columns!');
        return false;
    } else if (typeof this.fields === 'undefined' && typeof this.properties !== 'undefined') {
        var ops = getChildProperties(this.properties);
        // 存放Fields的定义
        this.fields = ops.fs;
        // 存放Columns的定义
        if (typeof this.columns === 'undefined') this.columns = ops.cs;
    }

    this.dataModel = Ext.define(this.entityName, {
        extend: 'Ext.data.Model',
        fields: this.fields
    });

    function getChildProperties(properties, parentName) {
        var fs = [], cs = [], ret = {};
        for (var i = 0, ilen = properties.length; i < ilen; i++) {
            var p = properties[i], f = {};

            if (typeof p === 'string') {
                // 允许属性的定义为一字符串的简单定义方式
                // 在这种情况下表明该属性仅将数据放在Store中,Grid中将不会有直接的展示(列)
                f.name = f.mapping = p.indexOf('.') != -1 ?  p.replace(/\./g, '_') : (typeof parentName === 'undefined' ? p : parentName + '_' + p);
            } else if (typeof p === 'object') {
                // 处理Ext.data.Field的定义
                if (!p.name) {
                    alert('第 ' + i + ' 个属性没有配置属性名!');
                    continue;
                } else {
                    f.name = p.name.indexOf('.') != -1 ? p.name.replace(/\./g, '_') : (typeof parentName === 'undefined' ? p.name : parentName + '_' + p.name);
                    f.mapping = typeof p.mapping !== 'undefined' ? p.mapping : (p.name.indexOf('.') != -1 ? p.name : (typeof parentName === 'undefined' ? p.name : parentName + '.' + p.name));
                    if (typeof p.calculate !== 'undefined') f.calculate = p.calculate;
                    if (typeof p.convert !== 'undefined') f.convert = p.convert;
                    if (typeof p.dateFormat !== 'undefined') f.dateFormat = p.dateFormat;
                    if (typeof p.defaultValue !== 'undefined') f.defaultValue = p.defaultValue;
                    if (typeof p.depends !== 'undefined') f.depends = p.depends;
                }

                // 处理Ext.grid.column.Column的定义
                if (typeof this.columns === 'undefined') {
                    var visiable = typeof p.visiable === 'undefined' ? true : p.visiable;
                    if (visiable) {
                        var c = Ext.apply({}, p);
                        c.text = p.text;
                        c.dataIndex = f.name;
                        if (typeof p.lockable === 'undefined' && !p.locked) {
                            c.lockable = false;
                        } else if (typeof p.lockable !== 'undefined') {
                            c.lockable = p.lockable;
                        }
                    }
                }
            }
            fs.push(f);

            if (typeof p.properties !== 'undefined') {
                var cp = getChildProperties(p.properties, f.name);
                fs = fs.concat(cp.fs);

                if (visiable && c) {
                    delete c.dataIndex;
                    delete c.width;
                    c.columns = cp.cs;
                }
            }

            if (visiable && c) cs.push(c);
        }

        ret.fs = fs;
        ret.cs = cs;
        return ret;
    }
},

initStore : function() {
    if (typeof this.storeConfig === 'undefined') {
        alert('Store必须配置(需要定义storeConfig)!');
        return false;
    }

    // 允许自定义store配置
    var mode = typeof this.storeConfig.mode === 'undefined' ? 'auto' : 'custom';
    if (mode == 'custom') {
        if (typeof this.storeConfig.config === 'undefined') {
            alert('使用自定义的Store,必须配置config!例如:storeConfig:{mode:\'custom\',config:{...}}');
            return false;
        } else {
            Ext.apply(this.storeConfig.config, this.pagerParam);
            this.store = Ext.create('Ext.data.Store', this.storeConfig.config);
        }
    } else {
        var storeCfg = {};
        storeCfg.autoLoad = typeof this.storeConfig.autoLoad === 'undefined' ? true : this.storeConfig.autoLoad;
        storeCfg.model = this.dataModel;

        if (typeof this.storeConfig.url !== 'undefined') {
            //var rp = Ext.isEmpty(this.storeConfig.rootProperty) ? ( this.entityName + '.result' ) : (this.storeConfig.rootProperty + '.result');
            var rp = Ext.isEmpty(this.storeConfig.rootProperty) ? ( this.entityName + '.result' ) : (this.storeConfig.rootProperty);
            var totalProperty = Ext.isEmpty(this.storeConfig.rootProperty) ?  this.entityName + '.totalCount' :(this.storeConfig.rootProperty +'.totalCount') ; 
            storeCfg.proxy = {
                type : 'ajax',
                url : this.storeConfig.url,
                timeout : 180000,
                reader : {
                    type : 'json',
                    rootProperty : rp,
                    totalProperty : totalProperty 
                },
                pageParam : 'pageNo',
                limitParam : 'pageSize',
                startParam : false,
                actionMethods : {
                    create : 'POST',
                    read : 'POST',
                    update : 'POST',
                    destroy : 'POST'
                } 
            };
            if (this.storeConfig.extraParams) storeCfg.proxy.extraParams = this.storeConfig.extraParams;
        } else {
            if (typeof this.storeConfig.proxy !== 'undefined') {
                storeCfg.proxy = proxy;
            } else {
                alert('使用缺省Store,必须配置proxy或者url!');
                return false;
            }
        }
        if (this.storeConfig.groupField) {
            storeCfg.groupField = this.storeConfig.groupField;
            if (typeof this.storeConfig.groupDir !== 'undefined') storeCfg.groupDir = this.storeConfig.groupDir;
        }
        storeCfg.listeners = {
            'load': function(store, records, successful) {
                this.fireEvent('load', store, records, successful);
            },
            scope: this
        };

        Ext.apply(storeCfg, this.pagerParam);
        this.store = Ext.create('Ext.data.Store', storeCfg);
    }
},

initToolBar : function() {
    if (typeof this.tbConfig === 'undefined') return;

    var tbMode = 'normal', tb = [];
    if (typeof this.tbConfig.mode !== 'undefined') tbMode = this.tbConfig.mode;
    if (tbMode === 'replace') {
        tb = tb.concat(this.tbConfig.items);
    } else if (tbMode === 'concat' || tbMode === 'normal') {
        // 如果传入了CUD按钮的配置,首先创建CUD按钮
        var cudBtn = [];
        if (this.createConfig) {
            if (this.createConfig.title) this.winCreateTitle = this.createConfig.title;
            var btnCreate = {
                id : this.createConfig.id || this.id + '_btnCreate',
                text : this.createConfig.text || this.btnCreateText,
                iconCls : this.createConfig.iconCls || 'create',
                tooltip : this.createConfig.tooltip || this.winCreateTitle,
                handler : this.createConfig.handler || this.onCreate,
                disabled : Ext.isEmpty(this.createConfig.disabled) ? false : this.createConfig.disabled,
                scope : this
            };
            cudBtn[cudBtn.length] = btnCreate;
        }
        if (this.modifyConfig) {
            if (this.modifyConfig.title) this.winModifyTitle = this.modifyConfig.title;
            var btnModify = {
                id : this.modifyConfig.id || this.id + '_btnModify',
                text : this.modifyConfig.text || this.btnModifyText,
                iconCls : this.modifyConfig.iconCls || 'modify',
                tooltip : this.modifyConfig.tooltip || this.winModifyTitle,
                handler : this.modifyConfig.handler || this.onModify,
                disabled : Ext.isEmpty(this.modifyConfig.disabled) ? true : this.modifyConfig.disabled,
                scope : this
            };
            cudBtn = cudBtn.concat([btnModify]);

            // 编辑按钮需要根据选中条目数量设置按钮状态
            var chkModifyItem = {id: btnModify.id, enableMulti: false};
            if (typeof this.modifyConfig.selectedCheck !== 'undefined') {
                Ext.apply(chkModifyItem, this.modifyConfig.selectedCheck);
            } 

            this.btnBeChecked.push(chkModifyItem);
        }
        if (this.removeConfig) {
            if (this.removeConfig.title) this.winRemoveTitle = this.removeConfig.title;
            var btnRemove = {
                id : this.removeConfig.id || this.id + '_btnRemove',
                text : this.removeConfig.text || this.btnRemoveText,
                iconCls : this.removeConfig.iconCls || 'remove',
                tooltip : this.removeConfig.tooltip || this.winRemoveTitle,
                handler : this.removeConfig.handler || this.onRemoveRec,
                disabled : Ext.isEmpty(this.removeConfig.disabled) ? true : this.removeConfig.disabled,
                scope : this
            };
            cudBtn = cudBtn.concat([btnRemove]);

            // 删除按钮需要根据选中条目数量设置按钮状态
            var chkRemoveItem = {id: btnRemove.id, enableMulti: true};
            if (typeof this.removeConfig.selectedCheck !== 'undefined') {
                Ext.apply(chkRemoveItem, this.removeConfig.selectedCheck);
            } 
            this.btnBeChecked.push(chkRemoveItem);
        }
        if (tbMode === 'normal') {
            tb = tb.concat(cudBtn);
        } else {
            // 合并传入的按钮配置和CUD按钮
            var tb2 = this.tbConfig.items, align = this.tbConfig.align || 'follow';
            // 检查是否有需要监控按钮状态的按钮
            for (var i = 0, ilen = tb2.length; i < ilen; i++) {
                var btnItem = tb2[i], chkSelSts = btnItem.selectedCheck || false, chkBtnItem = {};
                if (typeof btnItem.id === 'undefined') {
                    btnItem.id = this.id + '_toolbar_' + i;
                }
                chkBtnItem.id = btnItem.id;
                if (chkSelSts) {
                    Ext.apply(chkBtnItem,chkSelSts);
                    this.btnBeChecked.push(chkBtnItem);
                }
            }
            // 根据配置的按钮对齐方式合并按钮
            switch (align) {
                case 'left':
                    tb = tb.concat(tb2).concat(cudBtn);
                default:
                    tb = tb.concat(cudBtn).concat(tb2);
                    break;
            }
        }

        if (!this.singlePanel) {
            var btnToggleView = {
                xtype : 'segmentedbutton',
                id : this.entityName + '_btnToggleView',
                items : [{
                    id: this.entityName + '_view-toggle-detail',
                    text: this.detailViewText || 'Details',
                    iconCls: 'view-detail',
                    pressed: true
                }, {
                    id: this.entityName + '_view-toggle-icon',
                    text: this.iconViewText || 'Icons',
                    iconCls: 'view-icon'
                }],
                listeners : {
                    toggle : this.toggleView,
                    scope : this
                }
            };
            tb.push('->');
            tb.push(btnToggleView);
        }
    }

    this.toolbar = Ext.create('Ext.toolbar.Toolbar', {
        id : this.entityName + '_toolbar',
        dock : this.tbConfig.position || 'top',
        items : tb,
        border : true
    });
    this.dockedItems = [this.toolbar];
},

initPagerBar : function() {
    if (typeof this.bbConfig === 'undefined') return;

    var mode = this.bbConfig.mode || 'normal', bbcfg;
    if (mode === 'normal') {
        bbcfg = {
            store: this.store,
            displayInfo: typeof this.bbConfig.displayInfo === 'undefined' ? true : this.bbConfig.displayInfo
        };
        if (typeof this.bbConfig.afterPageText !== 'undefined') bbcfg.afterPageText = this.bbConfig.afterPageText;
        if (typeof this.bbConfig.beforePageText !== 'undefined') bbcfg.beforePageText = this.bbConfig.beforePageText;
        if (typeof this.bbConfig.displayMsg !== 'undefined') bbcfg.displayMsg = this.bbConfig.displayMsg;
        this.bbar = Ext.create('Ext.frf.PagingBar', bbcfg);
    } else {
        bbcfg = this.bbConfig.config;
        this.bbar = bbcfg;
    }
},

initColumnModel : function() {
    // 允许自定义columns配置,若未配置则使用根据properties生成的columns配置
    if (typeof this.columns === 'undefined') {
        this.columns = {
            defaults : {menuDisabled: true},
            items : this.columns
        };
    }

    if (this.gridConfig.columnMenuDisabled) {
        var columnItems = this.columns instanceof Array ? this.columns : this.columns.items;
        setColMenuDisabled(columnItems);
    }

    function setColMenuDisabled(cis) {
        for (var i = 0, ilen = cis.length; i < ilen; i++) {
            var ci = cis[i];
            //是否 启用列的菜单
            ci.menuDisabled = true;

            if (ci.columns) {
                var cii = ci.columns instanceof Array ? ci.columns : ci.columns.items;
                setColMenuDisabled(cii);
            }
        }
    }
},

// SelectionModel for Grid
initSelectionModel : function() {
    if (!this.multiSelect) {
        this.selModel = Ext.create('Ext.selection.RowModel', {
            enableKeyNav : false,
            allowDeselect : true,
            mode : 'SINGLE'
        });
    } else {
        this.selModel = Ext.create('Ext.selection.CheckboxModel', {
            enableKeyNav : false,
            allowDeselect : true,
            checkOnly : true,
            mode : 'SIMPLE',
            injectCheckbox : 0
        });
    }
},

initGrid : function() {
    this.gridConfig.id = this.id + '_Grid';
    this.gridConfig.columns = this.columns;
    this.gridConfig.selModel = this.selModel;
    this.gridConfig.store = this.store;
    if (checkFlex(this.columns)) {
        this.gridConfig.reserveScrollbar = true;
    }

    // 绑定事件监听,转发给本控件
    this.gridConfig.listeners = {
        selectionchange : this.onSelectionChange,
        select : this.onSelect,
        deselect : this.onDeSelect,
        beforeselect : this.onBeforeSelect,
        beforedeselect : this.onBeforeDeSelect,
        beforeitemclick : function(view, rec, item, idx, e){this.fireEvent('beforeitemclick', this, rec, idx);},
        beforeitemdblclick : function(view, rec, item, idx, e){this.fireEvent('beforeitemdblclick', this, rec, idx);},
        itemclick : function(view, rec, item, idx, e){this.fireEvent('itemclick', this, rec, idx);},
        itemdblclick : function(view, rec, item, idx, e){this.fireEvent('itemdblclick', this, rec, idx);},
        scope : this
    };
    if (this.plugins) this.gridConfig.plugins = this.plugins;

    this.grid = Ext.create('Ext.grid.Panel', this.gridConfig);

    // 检查columns中是否配置了flex,从而可以决定grid的layout,如果配置了flex,则需要将layout配置为auto;
    function checkFlex(columns) {
        var f = false;
        for (var i = 0, ilen = columns.length; i < ilen; i++) {
            var ci = columns[i];
            if (typeof ci.flex !== 'undefined') {
                f = true;
                break;
            }
        }
        return f;
    }
},

initView : function() {
    var defaultTpl = {
        tpl: [
            '<tpl for=".">',
                '<div class="viewItem" data-qtip="{name}">',
                    '{shortName}',
                '</div>',
            '</tpl>'
        ],
        selectedItemCls: 'viewItemSelected',
        itemSelector: 'div.viewItem',
        prepareData: function(data) {
            var name = data.name, re = new RegExp('^[\u0391-\uFFE5]{5}'), shortname;
            if (re.test(name))
                shortname = name.substr(0,3)+'...';
            else
                shortname = Ext.util.Format.ellipsis(name, 8);
            Ext.apply(data, {
                shortName: shortname
            });
            return data;
        }
    };
    Ext.applyIf(this.viewConfig, defaultTpl);

    this.viewConfig.store = this.store;
    if (!this.viewConfig.id && this.id) {
        this.viewConfig.id = this.id + '_View';
    }
    if (!this.multiSelect) {
        this.viewConfig.multiSelect = false;
    } else {
        this.viewConfig.multiSelect = true;
    }

    // 绑定事件监听,转发给本控件
    this.viewConfig.listeners = {
        selectionchange : this.onSelectionChange,
        select : this.onSelect,
        deselect : this.onDeSelect,
        beforeselect : this.onBeforeSelect,
        beforedeselect : this.onBeforeDeSelect,
        beforeitemclick : function(view, rec, item, idx, e){this.fireEvent('beforeitemclick', this, rec, idx);},
        beforeitemdblclick : function(view, rec, item, idx, e){this.fireEvent('beforeitemdblclick', this, rec, idx);},
        itemclick : function(view, rec, item, idx, e){this.fireEvent('itemclick', this, rec, idx);},
        itemdblclick : function(view, rec, item, idx, e){this.fireEvent('itemdblclick', this, rec, idx);},
        containerclick : function(){return false;},
        scope : this
    };
    this.view = Ext.create('Ext.view.View', this.viewConfig);
},

initList : function() {
    var centerConfig = {
        id : this.entityName + '_list',
        layout : 'card',
        region : 'center',
        border : false
    };
    if (this.singlePanel && this.defaultView === 'grid') {
        centerConfig.items = [this.grid];
    } else if (this.singlePanel && this.defaultView === 'view') {
        centerConfig.items = [this.view];
    } else if (!this.singlePanel) {
        centerConfig.items = [this.grid, this.view];
    }

// if (typeof this.searchConfig !== 'undefined') {
// centerConfig.margin = '0 3 3 3';
// centerConfig.border = true;
// }
this.list = Ext.create('Ext.panel.Panel', centerConfig);
this.items.push(this.list);
},

initSearchFrom : function() {
    var searchCfg = {
        id : this.id + '_searchForm',
        region : 'north',
        //margin : '3 3 3 3',
        hidden : typeof this.searchConfig.hidden === 'undefined' ? true : this.searchConfig.hidden,
        border : true,
        bodyStyle : 'border-bottom-width: 1px !important;',
        autoScroll : true,
        maxHeight : 200,
        bodyPadding : 10,
        layout : {
            type : 'anchor',
            constrainAlign : true
        },
        defaults : {
            labelAlign : 'right',
            style : 'float:left !important;'
        },
        defaultType : 'textfield',
        buttonAlign : 'center',
        buttons : [{
            text : this.btnSearchText,
            handler : this.onSearch,
            scope : this
        }, {
            text : this.btnResetText,
            handler : this.resetSearchForm,
            scope : this
        }]
    };

    if (typeof this.searchConfig.dockedEntry === 'undefined') {
        this.searchConfig.dockedEntry = true;
    }
    if (!this.searchConfig.dockedEntry) {
        Ext.apply(searchCfg, {
            title : this.searchPanelTitle || 'Search...',
            hidden : false,
            titleCollapse : true,
            collapseFirst : true,
            collapsible : true,
            collapsed : true,
            collapseMode : 'header'
        });
    } else {
        var btnSearch = Ext.create('Ext.button.Button', {
            id : this.entityName + '_btnToggleSearch',
            text : this.searchPanelTitle || 'Search',
            iconCls : 'search',
            enableToggle : true,
            handler : this.toggleSearch,
            scope : this
        });

        var tb = this.toolbar, idx = -1;
        for (var i = 0, ilen = tb.items.items.length; i < ilen; i++) {
            var tbi = tb.items.items[i];
            if (tbi.getXType() == 'tbfill') {
                idx = i + 1;
                break;
            }
        }
        if (idx == -1){
            tb.add('->');
            idx = tb.items.items.length + 1;
        }
        tb.insert(idx, btnSearch);
    }

    // 设置formpanel中的padding,最多允许每行三个field
    // 每个field的缺省宽度为275px

// var bodyWidth = Ext.getBody().getWidth();
// var availWidth = bodyWidth - 275 * 3 - 10; // 8为formpanel的margin
// if (availWidth > 0) {
// var lpadding, rpadding;
// var lpadding = rpadding = Math.floor(availWidth / 2); // 5为最小的padding,为避免超出宽度,向下取整
// if (lpadding > 30) {
// lpadding -= 30;
// rpadding += 30;
// } else {
// lpadding = 0;
// rpadding = Math.floor(availWidth);
// }
// searchCfg.bodyPadding = '10 ' + rpadding + ' 5 ' + lpadding;
// }

    var items = [], hiddenItems = [];
    for (var key in this.searchConfig) {
        if (key == 'dockedEntry' || key == 'hidden') continue;

        var itemConfig = this.searchConfig[key];
        // 通用配置
        var item = {
            id: this.id + '_search_' + this.entityName + '_' + key.replace(/\./g, '_'),
            name : key,
            fieldLabel : itemConfig.fieldLabel
        };
        Ext.applyIf(item, itemConfig);

        // 非通用配置
        if (item.xtype === 'hidden') {
            hiddenItems.push(item);
            continue;
        }
        if (item.xtype === 'datefield') item.format = 'Y-m-d';
        if (item.xtype === 'combo') {
            item.typeAhead = true;
            item.editable = true;
            item.triggerAction = 'all';
            item.forceSelection = true;
            if(!item.store)
            {
                item.store = Ext.create('Ext.data.ArrayStore', {
                    fields : ['val', 'text'],
                    data : item.data
                });
            }

            if (!item.valueField ) item.valueField = 'val';
            if (!item.displayField ) item.displayField = 'text';
            if (!item.editable) {
                item.typeAhead = false;
                item.editable = false;
            }
            /** liang.hl 2015-05-27 输入关键字检索查询 start modified**/
            item.listeners = {
                    'beforequery':function(e){
                        var combo = e.combo;  
                        if(!e.forceAll){  
                            var input = e.query;  
                            if(input != null && input != "")
                            {
                                // 检索的正则
                                var regExp = new RegExp(".*" + input + ".*");
                                // 执行检索
                                combo.store.filterBy(function(record,id){  
                                    // 得到每个record的项目名称值
                                    var text = record.get(combo.displayField);  
                                    return regExp.test(text); 
                                });
                                combo.expand();  
                                return false;
                            }else{
                                combo.store.clearFilter();
                                combo.expand();  
                                 return false;
                            }
                        }else{
                            combo.store.clearFilter();
                            combo.expand();  
                             return false;
                        }

                    },
                    scope: this
            };
            /** liang.hl 2015-05-27 end modified**/
        }

        items.push(item);
    }

    searchCfg.items = items.concat(hiddenItems);
    this.searchForm = Ext.create('Ext.form.Panel', searchCfg);
    this.items.push(this.searchForm);
},

initFormPanel : function() {
    if (typeof this.formConfig === 'undefined') {
        alert('表单未配置!');
        return;
    }

    var formPanelCfg = {
        modal : true,
        autoScroll : true,
        dockedItems : [{
            xtype : 'toolbar',
            dock : 'bottom',
            ui : 'footer',
            defaults : {minWidth : 75},
            layout : {
                pack : 'center'
            },
            items : [{
                xtype : 'button',
                text : this.btnConfirmText,
                handler : this.confirmForm,
                scope : this
            }, {
                xtype : 'button',
                text : this.btnCancelText,
                handler : this.cancelForm,
                scope : this
            }]
        }],
        closable : true,
        closeAction : 'hide',
        defaults : {
            labelAlign : 'right',
            labelWidth : 100,
            width: 365
        },
        draggable : true,
        floating : true,
        frame : true,
        width : this.formPanelWidth || 800,
        maxHeight : 600,
        iconCls : 'modalWin',
        id : 'formPanel_' + this.entityName,
        loader : {loadMask: true},
        title : this.currentFormMode === 'Create' ? this.winCreateTitle : this.winModifyTitle,
        bodyPadding : '5 20 0 0',
        layout : {
            type : 'table',
            columns : 2,
            tableAttrs : {
                style : {
                    margin : '0px 20px 0px 0px',
                    width : '100%'
                }
            }
        },
        listeners : {
            beforeshow : this.onFormBeforeShow,
            close : this.resetForm,
            scope : this
        }
    };

    // 根据配置加入表单元素
    var items = [], hiddenItems = [], curCount = 0;
    for (var key in this.formConfig) {
        var itemConfig = this.formConfig[key], itemLayout = (typeof itemConfig.layout !== 'undefined' || itemConfig.xtype === 'textarea') ? 'form' : 'column';
        if (typeof this.formConfig[key].xtype === 'undefined') {
            itemConfig.xtype = 'textfield';
        }
        // 通用配置
        var item = {
            id : 'form_' + this.entityName + '_' + key.replace(/\./g, '_'),
            name : this.entityName + '.' + (itemConfig['fieldName'] || key)
        };
        Ext.applyIf(item, itemConfig);
        if (typeof item.layout !== 'undefined') delete item.layout;
        if (typeof item.allowBlank !== 'undefined') item.fieldLabel = item.allowBlank ? item.fieldLabel : '<span style="font-weight:bold;color:red">*</span> ' + item.fieldLabel;
        this.formElements.push(item.id);
        // 非通用配置
        if (item.xtype === 'hidden') {
            hiddenItems.push(item);
            continue;
        }
        if (typeof itemConfig.fieldVType !== 'undefined') item.vtype = itemConfig.fieldVType;
        if (item.xtype === 'datefield') item.format = item.format || 'Y-m-d';
        if (item.xtype === 'timefield') item.format = item.format || 'H:i:s';
        if (item.xtype === 'combo') {
            item.typeAhead = true;
            item.triggerAction = 'all';
            item.editable = true;
            item.forceSelection = true;
            item.lazyInit = false;
            item.store = Ext.create('Ext.data.ArrayStore', {
                fields : ['val', 'text'],
                data : item.data
            });
            /** liang.hl 2015-3-26 modified**/
            item.valueField = item.valueField || 'val';
            item.displayField = item.displayField || 'text';
            /** liang.hl 2015-3-26 modified**/
            /** liang.hl 2015-05-27 输入关键字方便查询 start modified**/
            item.listeners = {
                    'beforequery':function(e){
                        var combo = e.combo;  
                        if(!e.forceAll){  
                            var input = e.query;  
                            if(input != null && input != "")
                            {
                                // 检索的正则
                                var regExp = new RegExp(".*" + input + ".*");
                                // 执行检索
                                combo.store.filterBy(function(record,id){  
                                    // 得到每个record的项目名称值
                                    var text = record.get(combo.displayField);  
                                    return regExp.test(text); 
                                });
                                combo.expand();  
                                return false;
                            }else{
                                combo.store.clearFilter();
                                combo.expand();  
                                 return false;
                            }
                        }else{
                            combo.store.clearFilter();
                            combo.expand();  
                             return false;
                        }

                    },
                    scope: this
            };
            /** liang.hl 2015-05-27 end modified**/
        }

        if (item.xtype === 'textarea') {
            item.width = item.width || 754;
            item.height = item.height || 50;
        }
        if (item.xtype === 'radiogroup' || item.xtype === 'checkboxgroup') {
            item.items = [];
            for (var k = 0, klen = item.data.length; k < klen; k++) {
                var config = {
                    id : item.id + '_' + k,
                    name : item.name,
                    boxLabel : item.data[k][1],
                    inputValue : item.data[k][0]
                };
                if (!Ext.isEmpty(item.value)) {
                    if (item.data[k][0] == item.value) config.checked = true;
                }
                item.items.push(config);
            }
            if (item.data.length > 2) itemLayout == 'form';
        }
        // 根据布局将Item加入,缺省为两列布局,textarea为单列布局
        if (itemLayout === 'column') {
            items.push(item);
        } else {
            if (curCount %  2 != 0) {
                items[items.length - 1].colspan = 2;
            }
            item.colspan = 2;
            items.push(item);
        }
        curCount++;
    }
    formPanelCfg.items = items.concat(hiddenItems);

    this.formPanel = Ext.create('Ext.panel.Panel', formPanelCfg);
    this.formPanel.show();
    this.formPanel.center();
},

// private
// 视图切换
toggleView : function(btn, toggledBtn, isPressed) {
    this.fireEvent('beforeviewtoggle', this);

    var id = toggledBtn.id;
    if (id == this.entityName + '_view-toggle-icon' && isPressed) {
        this.list.getLayout().setActiveItem(this.view);
    } else if (id == this.entityName + '_view-toggle-detail' && isPressed) {
        this.list.getLayout().setActiveItem(this.grid);
    }
},

// private
// 查询表单显示切换
toggleSearch : function(btn, e) {
    var prsd = btn.pressed;
    if (prsd) {
        this.searchForm.show();
    } else {
        this.searchForm.hide();
    }
},

// private
onSelect: function(selModel, rec) {
    this.fireEvent('select', selModel, rec);
},

// private
onDeSelect: function(selModel, rec) {
    this.fireEvent('deselect', selModel, rec);
},

// private
onBeforeSelect: function(selModel, rec) {
    this.fireEvent('beforeselect', selModel, rec);
},

// private
onBeforeDeSelect: function(selModel, rec) {
    this.fireEvent('beforedeselect', selModel, rec);
},

// private
onSelectionChange: function(selModel, selected) {
    var activeItem = this.list.getLayout().getActiveItem();

    if (!this.singlePanel) {
        // 首先要同步两个视图的选中项
        var inactSelModel;

        if (activeItem.id == this.id + '_View') {
            inactSelModel = this.grid.getSelectionModel();
        } else {
            inactSelModel = this.view.getSelectionModel();
        }
        inactSelModel.deselectAll(true);
        if (selected.length > 0) {
            inactSelModel.select(selected, false, true);
        }
    }

    // 设置按钮状态
    this.checkBtnStatus();

    this.fireEvent('selectionchange', selModel, selected);
},

// private
checkBtnPermission: function(key) {
    if (typeof aclMap !== 'undefined' && typeof aclResMap !== 'undefined') {
        var toolbars = this.getDockedItems('toolbar');
        for (var i = 0, ilen = toolbars.length; i < ilen; i++) {
            var tb = toolbars[i];
            tb.items.each(function(item, idx){
                var id = item.getId();
                if (typeof aclMap[id] !== 'undefined') {
                    var perm = aclResMap[aclMap[id]] || true;
                    item.setDisabled(!perm);
                }
            }, this);
        }
    }
},

// private
checkBtnStatus: function() {
    var selModel = this.list.getLayout().getActiveItem().getSelectionModel();
    var hasSelection = selModel.hasSelection();
    var hasMulti = selModel.getSelection().length > 1 ? true : false;

    for (var i = 0, ilen = this.btnBeChecked.length; i < ilen; i++) {
        var btnItem = this.btnBeChecked[i];
        if(btnItem.flag) return;
        //conslole.log(btnItem.flag);
        if (!hasSelection) {    // 未选择任何记录,disable
            Ext.getCmp(btnItem.id).disable();
        } else {
            var perm = true;
            // 已选中多条记录但不允许多选
            if (hasMulti && !btnItem.enableMulti) perm = false;
            // 如果设置了条件匹配项
            if (typeof btnItem.condition !== 'undefined') {
                if (typeof btnItem.condition === 'object'){
                    for (var key in btnItem.condition) {
                        var recs = selModel.getSelection();
                        for (var j = 0, jlen = recs.length; j < jlen; j++) {
                            var rec = recs[j];
                            //如果存在多条件
                            var value = btnItem.condition[key] + '';
                            if(value.indexOf(',') != -1){
                                //将条件按逗号分隔为数组
                                var arr_condition = value.split(',');
                                //如果值在数组中不存在,则没有权限
                                if (!inArray(rec.get(key.toString()),arr_condition,false)) {
                                    perm = false;
                                    break;
                                }
                            }else if (rec.get(key.toString()) != btnItem.condition[key]) {
                                perm = false;
                                break;
                            }


                        }
                        if (!perm) break;
                    }
                }
            }

            if (!perm)
                Ext.getCmp(btnItem.id).disable();
            else {  // enable之前先检查权限
                if (typeof aclMap !== 'undefined' && typeof aclResMap !== 'undefined') {
                    if (typeof aclMap[btnItem.id] !== 'undefined') {
                        if (typeof aclResMap[aclMap[id]] !== 'undefined') perm = aclResMap[aclMap[id]];
                    }
                }
                if (perm) Ext.getCmp(btnItem.id).enable();
            }
        }
    }
},

// private
onFormBeforeShow: function() {
    for (var i = 0, ilen = this.formElements.length; i < ilen; i++) {
        var comp = Ext.getCmp(this.formElements[i]);
        //var key = this.formElements[i].split('_').pop();
        var key = this.formElements[i].substring(('form_' + this.entityName + '_').length);
        //var name = comp.getName().replace(this.entityName + '.', '');

        if (this.formConfig[key].createOnly) {
            if (this.currentFormMode == 'Create') comp.enable();
            else comp.disable();
        }
        if (this.formConfig[key].modifyOnly) {
            if (this.currentFormMode == 'Modify') comp.enable();
            else comp.disable();
        }
    }
},

// private
setFormValue: function() {
    var activeItem = this.list.getLayout().getActiveItem();

    var selRec = activeItem.getSelectionModel().getLastSelected();
    for (var i = 0, ilen = this.formElements.length; i < ilen; i++) {
        var comp = Ext.getCmp(this.formElements[i]);
        //var name = comp.getName().replace(this.entityName + '.', '');
        //var name = this.formElements[i].split('_').pop();
        var name = this.formElements[i].substring(('form_' + this.entityName + '_').length);
        var val = '';
        if (name.indexOf('.') == -1) {
            val = selRec.get(name);
        } else {
            var field = name.replace(/\./g, '_');
            if (typeof selRec.get(field) !== 'undefined') {
                val = selRec.get(field);
            } else {
                var path = '[\'' + name.split('.').join('\'][\'') + '\']';
                try {
                    val = eval('selRec.raw' + path);
                } catch(e) {}
            }
        }
        if (comp.getXType() === 'datefield') {
            if(typeof val !== 'undefined') {
                if(val != null){
                    val = val.substr(0, 10);
                }
            }

            comp.setValue(val);
        }
        if (comp.xtype === 'checkboxgroup' || comp.xtype === 'radiogroup') {
            var objVal = {};
            if(comp.xtype === 'radiogroup'){
                objVal[comp.getName()] = val;
            }else{
                objVal[comp.getName()] = val.split(',');
            }
            comp.setValue(objVal);
        } else if (val != null && comp.xtype === 'combo') {
            comp.setValue(val);
        } else if (val != null && comp.xtype === 'combo' && comp.multiSelect) {
            comp.setValue(val.split(','));
        } else if (comp.xtype === 'textareafield') {
            comp.setValue(val.replace(/<br>/g, '\n'));
        } else {
            if (typeof val !== 'undefined') {
                comp.setValue(val);
            }
        }
    }
},

// private
confirmForm: function() {
    var status = this.currentFormMode;
    if (status === 'Create') {
        this.doCreate();
    } else if (status === 'Modify') {
        this.doModify();
    }
},

// private
resetForm: function() {
    for (var i = 0, ilen = this.formElements.length; i < ilen; i++) {
        var comp = Ext.getCmp(this.formElements[i]);
        comp.reset();
    }
},

//private
cancelForm: function() {
    this.formPanel.hide();
    this.resetForm();
},

onCreate : function() {
    if (typeof this.createConfig !== 'undefined') {
        this.currentFormMode = 'Create';
        if (typeof this.createConfig.mode === 'undefined' || this.createConfig.mode == 'formPanel') {
            if (this.formPanel) {
                this.formPanel.setTitle(this.winCreateTitle);
                this.formPanel.show();
            } else {
                this.initFormPanel();
            }

            this.fireEvent('beforecreate', this);
        } else {
            var config = {
                id : this.entityName + '_winCreate',
                title : this.createConfig.title || 'Record Create',
                layout : this.createConfig.layout || 'fit',
                iconCls : this.createConfig.iconCls || 'modalWin',
                closeable : true,
                closeAction : 'destroy',
                resizable : true,
                modal : this.createConfig.modal || true,
                width : this.createConfig.width || 800,
                height : this.createConfig.height || 600,
                items : [{
                    xtype : "component",
                    id : 'iframe_' + this.entityName + '_winCreate',
                    autoEl : {
                        tag : 'iframe',
                        src : 'about:blank',
                        width : '100%',
                        height : '100%',
                        frameBorder : 0,
                        scrolling : 'auto'
                    },
                    listeners : {
                        load : {
                            element: 'el',
                            fn: function () {
                                this.parent().unmask();
                            }
                        },
                        render : function () {
                            this.up('panel').body.mask('页面加载中...');
                        }
                    }
                }],
                listeners : {
                    resize : function(win, width, height, eOpts) {
                        this.createConfig.width = width;
                        this.createConfig.height = height;
                    },
                    scope : this
                }
            };

            this.winCreate = Ext.create('Ext.window.Window', config);

            this.fireEvent('beforecreate', this);

            this.winCreate.show();
            this.winCreate.center();
            Ext.get('iframe_' + config.id).set({
                src : this.createConfig.url
            });
        }
    } else
        return;

},

doCreate : function() {
    var paramData = {}, validate = true;
    for (var i = 0, ilen = this.formElements.length; i < ilen; i++) {
        var comp = Ext.getCmp(this.formElements[i]);
        if (!comp.validate()) {
            validate = false;
        }
    }

    if (validate) {
        for (var i = 0, ilen = this.formElements.length; i < ilen; i++) {
            var comp = Ext.getCmp(this.formElements[i]);
            var name = comp.getName();
            var val = comp.getXType() === 'datefield'  || comp.getXType() === 'timefield' ? comp.getRawValue() : comp.getValue();
            if (!Ext.isEmpty(val)) paramData[name] = val;
        }
        if (this.createConfig.additionalParams) {
            Ext.apply(paramData, this.createConfig.additionalParams);
        }

        if(Ext.isFunction(this.createConfig.preHandler))
        {
            this.createConfig.preHandler.call(this,paramData);
        }

        this.currentAjaxAction = 'create';
        Ext.Ajax.request({
            url: this.createConfig.url,
            params: paramData,
            success: this.onAjaxSuccess,
            failure: this.onAjaxFaliure,
            scope: this
        });
    }
},

onModify : function() {
    if (typeof this.modifyConfig !== 'undefined') {
        this.currentFormMode = 'Modify';
        if (typeof this.modifyConfig.mode === 'undefined' || this.modifyConfig.mode == 'formPanel') {
            if (this.formPanel) {
                this.setFormValue();
                this.formPanel.setTitle(this.winModifyTitle);
                this.formPanel.show();
            } else {
                this.initFormPanel();
                this.setFormValue();
            }

            this.fireEvent('beforemodify', this);
        } else {
            var paramConfig = this.modifyConfig.paramConfig || {
                'uuid' : 'UUID'
            };
            var sUrl = this.modifyConfig.url;
            var recs = this.view.getSelectionModel().getSelection();
            var oParams = {};
            for (var i = 0, ilen = recs.length; i < ilen; i++) {
                // 根据每个参数配置获取相应的值
                for (var key in paramConfig) {
                    var param2Cols = paramConfig[key].split(';'), paramValue = [];
                    // 当需要多个字段的值拼一个参数的情况
                    for (var j = 0, jlen = param2Cols.length; j < jlen; j++) {
                        // 判断是直接的字段名还是包含对象路径
                        if (param2Cols[j].indexOf('[') == -1) { // 直接的字段名就将值取出
                            paramValue[paramValue.length] = recs[i].get(param2Cols[j]);
                        } else { // 包含路径名
                            var recData = recs[i].data;
                            var getVal = Ext.data.JsonReader.prototype.createAccessor(param2Cols[j]);
                            var val = getVal(recData);
                            paramValue[paramValue.length] = val;
                        }
                    }

                    if (Ext.isEmpty(oParams[key])) {
                        oParams[key] = [];
                    }
                    oParams[key].push(paramValue.join(';'));
                }
            }
            if (sUrl.indexOf('?') == -1) {
                sUrl += '?';
            } else {
                sUrl += '&';
            }
            var urlParams = [];
            for (var key in oParams) {
                urlParams[urlParams.length] = key + '=' + oParams[key].join(',');
            }
            sUrl += urlParams.join('&');

            var config = {
                id : this.entityName + '_winModify',
                title : this.modifyConfig.title || 'Record Modify',
                layout : this.modifyConfig.layout || 'fit',
                iconCls : this.modifyConfig.iconCls || 'modalWin',
                closeable : true,
                closeAction : 'destroy',
                resizable : true,
                modal : this.modifyConfig.modal || true,
                width : this.modifyConfig.width || 640,
                height : this.modifyConfig.height || 480,
                items : [{
                    xtype : 'component',
                    id : 'iframe_' + this.entityName + '_winModify',
                    autoEl : {
                        tag : 'iframe',
                        src : 'about:blank',
                        width : '100%',
                        height : '100%',
                        frameBorder : 0,
                        scrolling : 'auto'
                    },
                    listeners : {
                        load : {
                            element: 'el',
                            fn: function () {
                                this.parent().unmask();
                            }
                        },
                        render : function () {
                            this.up('panel').body.mask('页面加载中...');
                        }
                    }
                }],
                listeners : {
                    resize : function(win, width, height, eOpts) {
                        this.modifyConfig.width = width;
                        this.modifyConfig.height = height;
                    },
                    scope : this
                }
            };

            this.winModify = Ext.create('Ext.window.Window', config);

            this.fireEvent('beforemodify', this);

            this.winModify.show();
            this.winModify.center();
            Ext.get('iframe_' + config.id).set({
                src : this.modifyConfig.url
            });
        }
    } else
        return;
},

doModify : function() {
    var paramData = {}, validate = true;
    for (var i = 0, ilen = this.formElements.length; i < ilen; i++) {
        var comp = Ext.getCmp(this.formElements[i]);
        if (!comp.validate()) {
            validate = false;
        }
    }

    if (validate) {
        for (var i = 0, ilen = this.formElements.length; i < ilen; i++) {
            var comp = Ext.getCmp(this.formElements[i]);

            var name = comp.getName();

// if (name === this.entityName + '.uuid') name = this.entityName + '._.uuid';

            var val = comp.getXType() === 'datefield'  || comp.getXType() === 'timefield' ? comp.getRawValue() : comp.getValue();
            //var val = comp.getXType() === 'timefield' ? comp.getRawValue() : comp.getValue();
            if (!Ext.isEmpty(val)) paramData[name] = val;
        }
        if (this.modifyConfig.additionalParams) {
            Ext.apply(paramData, this.modifyConfig.additionalParams);
        }

        if(Ext.isFunction(this.modifyConfig.preHandler))
        {
            this.modifyConfig.preHandler.call(this,paramData);
        }

        this.currentAjaxAction = 'modify';
        Ext.Ajax.request({
            url: this.modifyConfig.url,
            params: paramData,
            success: this.onAjaxSuccess,
            failure: this.onAjaxFailure,
            scope: this
        });
    }
},

onRemoveRec : function() {
    var msgTitle = this.confirmTitle || 'Confirm', msgDelConf = this.removeConfirmMsg || 'Are you sure to remove selected item(s)?';
    if (typeof globalVar !== 'undefined') {
        if (typeof globalVar.msgs !== 'undefined') {
            if (typeof globalVar.msgs.confirmTitle !== 'undefined')
                msgTitle = globalVar.msgs.confirmTitle;
            if (typeof globalVar.msgs.msgDelConf !== 'undefined')
                msgDelConf = this.removeConfirmMsg || globalVar.msgs.msgDelConf;
        }
    }
    Ext.MessageBox.confirm(msgTitle, msgDelConf, function(btn){
        if (btn == 'yes') {
            this.fireEvent('beforeremove', this);
            this.doRemoveRec();
        }
    }, this);
},

doRemoveRec : function() {
    var paramsData = {}, activeItem = this.list.getLayout().getActiveItem();
    var selRecs = activeItem.getSelectionModel().getSelection();
    var paramCfg = this.removeConfig.paramConfig;
    if (!paramCfg) {
        paramCfg = {};
        paramCfg[this.entityName + '._.ids'] = 'UUID';
    }

    if (selRecs.length == 0) return;
    else {
        var paramData = {};
        for (var i = 0, ilen = selRecs.length; i < ilen; i++) {
            // 根据每个参数配置获取相应的值
            for (var key in paramCfg) {
                var param2Cols = paramCfg[key].split(';'), paramValue = [];
                // 当需要多个字段的值拼一个参数的情况
                for (var j = 0, jlen = param2Cols.length; j < jlen; j++) {
                    // 判断是直接的字段名还是包含对象路径
                    if (param2Cols[j].indexOf('[') == -1) { // 直接的字段名就将值取出
                        paramValue[paramValue.length] = selRecs[i].get(param2Cols[j]);
                    } else { // 包含路径名
                        var recData = selRecs[i].data;
                        var getVal = Ext.data.JsonReader.prototype.createAccessor(param2Cols[j]);
                        var val = getVal(recData);
                        paramValue[paramValue.length] = val;
                    }
                }

                if (Ext.isEmpty(paramData[key])) {
                    paramData[key] = [];
                }
                paramData[key].push(paramValue.join(';'));
            }
        }
        for (var key in paramData) {
            paramData[key] = paramData[key].join(',');
        }

        this.currentAjaxAction = 'remove';
        Ext.Ajax.request({
            url: this.removeConfig.url,
            params: paramData,
            success: this.onAjaxSuccess,
            failure: this.onAjaxFailure,
            scope: this
        });
    }
},

onSearch : function() {
    if(!this.searchForm.isValid()) return;

    var data = this.searchForm.getForm().getValues(), oParam = [];
    for (var key in data) {
        if (this.searchConfig[key]['assistfield']) {
            continue;
        }

        var item = {};
        item.name = this.searchConfig[key]['name'] || key;
        item.type = this.searchConfig[key]['type'] || 'string';
        item.operator = this.searchConfig[key]['operator'] || '';
        item.value = Ext.String.trim(data[key].toString());
        oParam.push(item);
    }

    var params = this.prepareSearchParams(oParam);
    this.doSearch(params);
},

doSearch : function(params) {
    this.fireEvent('beforesearch', this, params);
    this.store.loadPage(1, {params : params});
    this.fireEvent('aftersearch', this, params);
},

resetSearchForm : function() {
    if (this.searchForm) {
        this.searchForm.getForm().reset();

        // 清除Store的Proxy中的extraParams,因为此时extraParams可能已经被改动了,用自身保持的一份克隆拷贝替代
        var proxy = this.store.getProxy();
        for (var key in proxy.extraParams) {
            delete proxy.extraParams[key];
        }
        for (var key in this.baseParams) {
            proxy.extraParams[key] = this.baseParams[key];
        }

        // 如果pageSize被改动过,需要将改后的pageSize置入
        if (typeof Ext.getCmp('changepagesize') !== 'undefined') {
            proxy.extraParams.pageSize = Ext.getCmp('changepagesize').getValue();
        }

        this.store.load();
    }
},

prepareSearchParams : function(dataObject) {
    var params = {};
    if (dataObject instanceof Array) {
        var whereCondition = false;
        if (!Ext.isEmpty(this.whereCondition)) whereCondition = this.whereCondition;
        if (!whereCondition) { //不作为Where子句的条件进行查询
            for (var i = 0, ilen = dataObject.length; i < ilen; i++) {
                var name = this.entityName + '.w.' + dataObject[i]['name'], type = dataObject[i]['type'], operator = dataObject[i]['operator'], value = dataObject[i]['value'];
                // 忽略空值
                if (Ext.isEmpty(value)) continue;
                params[name] = value;
            }
        } else { // 作为Where子句的条件进行查询
            var whereConditionKey = this.entityName + '._.' +'whereCondition';
            var conditions = [];
            for (var i = 0, ilen = dataObject.length; i < ilen; i++) {
                var name = dataObject[i]['name'], type = dataObject[i]['type'], operator = dataObject[i]['operator'], value = dataObject[i]['value'], sCond = '';
                // 忽略空值
                if (Ext.isEmpty(value)) continue;
                conditions.push(name);
            }
            params[whereConditionKey] = conditions.join(' and ');
        }
    }

    return params;
},

onAjaxSuccess : function(response, options) {
    var resp = Ext.decode(response.responseText);
    if (resp['frf_success']) {
        if (this.formPanel) {
            if (!this.formPanel.isHidden()) this.formPanel.hide();
        }
        if (this.winCreate) {
            if (!this.winCreate.isHidden()) this.winCreate.hide();
        }
        if (this.winModify) {
            if (!this.winModify.isHidden()) this.winModify.hide();
        }
        Ext.MessageBox.show({
            title : globalVar.msgs.alertTitle,
            msg : globalVar.msgs.msgSuccess,
            icon : Ext.Msg.INFO,
            buttons: Ext.Msg.OK
        });
        this.store.load();
        this.resetForm();

        switch (this.currentAjaxAction) {
            case 'create':
                this.fireEvent('aftercreate', options, this);
                break;
            case 'modify':
                this.fireEvent('aftermodify', options, this);
                break;
            case 'remove':
                this.fireEvent('afterremove', options, this);
                break;
        }
    } else {
        Ext.MessageBox.show({
            title : globalVar.msgs.alertTitle,
            msg :resp['frf_exception'] || globalVar.msgs.msgFailure,
            icon : Ext.Msg.ERROR,
            buttons: Ext.Msg.OK
        });
    }
},

onAjaxFailure : function(response, options) {
    Ext.MessageBox.show({
        title : globalVar.msgs.alertTitle,
        msg : globalVar.msgs.msgFailure,
        icon : Ext.Msg.ERROR,
        buttons: Ext.Msg.OK
    });
},

// stuff
getStore: function() {
    return this.store;
},

getSelectionModel: function() {
    var activeItem = this.list.getLayout().getActiveItem();
    return activeItem.getSelectionModel();
},

/***************************add gridviewdragdrop plugin     modified by song.hl at 2014-12-24   begin***************************/
getItemSelector : function() {
    if (!this.singlePanel || (this.singlePanel && this.defaultView === 'grid')) {
        return this.grid.view.getItemSelector();
    }
},
getRecord: function(node) {
    if (!this.singlePanel || (this.singlePanel && this.defaultView === 'grid')) {
         node = this.grid.view.getNode(node);
         if (node) {
            var recordIndex = node.getAttribute('data-recordIndex');
            if (recordIndex) {
                recordIndex = parseInt(recordIndex, 10);
                if (recordIndex > -1) {
                    return this.store.data.getAt(recordIndex);
                }
            }
            return this.dataSource.data.get(node.getAttribute('data-recordId'));
        }
    }
    return null;
}
/***************************modified by song.hl at 2014-12-24   end***************************/

});

/**

  • 指定value是否在数组中存在
  • @param {} needle 查找value
  • @param {} array 源数组
  • @param {} bool 是否返回值在数组中的索引,true:返回索引 false:返回true 或false
  • @return {} */ function inArray(needle,array,bool) { if(typeof needle=="string"||typeof needle=="number") { for(var i in array) { if(needle == array[i]) { if(bool) { return i; } return true; } } return false; } }
qq_29271533
qq_29271533   2017.01.13 15:23

这是listpanel的内容

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!