Extjs 드롭다운 Grid 팝업

7227 단어 ExtJs
/**

 *  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,

            width: 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;    

    }

    

});

좋은 웹페이지 즐겨찾기