• Extjs 弹出下拉Grid


    /**
     * 系统通用下拉选择Gird
     */
    Ext.define("Common.picker.GridPicker", {
        extend: "Ext.form.field.Picker",
        alias: 'widget.gridPicker',
        
        displayField: null,
        
        valueField: null,
        
        matchFieldWidth: false,
        
        store: null,
        
        columns: null,
        
        pickerWidth: 400,
        
        pickerHeight: 300,
        
        editable: false,
        
        /**
         * 创建Picker
         * @return {Ext.grid.Panel} 
         */
        createPicker: function() {
            var me = this,
                picker = me.createComponent();
            
            picker.on("itemclick", me.onItemClick, me);
            
            me.on("focus", me.onFocusHandler, me);
            return picker;
        },
        
        /**
         * 创建gridPanel,子类可以扩展返回个性化grid(比如条件查询等)
         * @return {Ext.grid.Panel} 
         */
        createComponent: function() {
            var me = this,
                picker = Ext.create("Ext.grid.Panel", {
                floating: true,
                store: me.store,
                columns: me.columns,
                 me.pickerWidth,
                heigkt: me.pickerHeight,
                dockedItems: [{
                    xtype: 'pagingtoolbar',
                    store: me.store,
                    dock: 'bottom',
                    displayInfo: true
                }]
            });
            return picker;
        },
        
        /**
         * 处理grid行单击事件
         */
        onItemClick: function(view, record, item, index, e, eOpts ) {
            var me = this;
            me.setValue(record.get(me.valueField));
            me.getPicker().hide();
            me.inputEl.focus();
        },
        
        /**
         * 获得焦点弹出
         */
        onFocusHandler: function() {
            var me = this;
            if(!me.isExpanded) {
                this.expand();
                this.focus();
            }
        },
        
        /**
         * 设置值
         * @param {Mixed} value
         * @return {Common.picker.GridPicker} this
         */
        setValue: function(value) {
             var me = this,
                  record;
             
             me.value = value;
             
             if (me.store.isLoading()) {
                 //当store加载暂时不做处理
                 return me;
             }
             
             if(value === undefined) {
                 return me;
             } else {
                 record = me.getPicker().getSelectionModel().getSelection()[0];
             }
             
             me.setRawValue(record ? record.get(me.displayField) : '');
             
             return me;
        },
        
        /**
         * 返回field的值
         * @return {String}
         */
        getValue: function() {
            return this.value;   
        },
        
        /**
         * 返回提交到服务器端的值
         * @return {String}
         */
        getSubmitValue: function(){
            return this.value;    
        }
        
    });
  • 相关阅读:
    inotify和rsync实现数据实时同步
    Powershell在相应的文件夹下用管理员模式打开
    LOJ6498「雅礼集训 2018 Day2」农民
    LOJ6502「雅礼集训 2018 Day4」Divide
    LOJ6501「雅礼集训 2018 Day4」Cube
    2021-10-11 杂题选听
    LOJ6507 「雅礼集训 2018 Day7」A
    LOJ6497「雅礼集训 2018 Day1」图
    CF103E Buying Sets
    CF266D BerDonalds(图的绝对中心)
  • 原文地址:https://www.cnblogs.com/daxin/p/3177334.html
Copyright © 2020-2023  润新知