1. 程式人生 > >ExtJS4下拉列表框寬度自適應

ExtJS4下拉列表框寬度自適應

  /**
         * 獲取下拉列表框定義
         */
        getBoxTextEditor: function (box_text_store) {
            //定義了下拉列表框
            var editor = new Ext.form.ComboBox({
                editable: false,
                displayField: "text",
                valueField: "id",
                editable: true,
                typeAhead: true,

                mode: "local",
                store: new Ext.data.ArrayStore({
                    fields: ["id", "text"],
                    data: box_text_store
                }),
                listeners: {
                    'focus': {
                        fn: function (e) {
                            //把下拉框展開後的列表部分設為寬度自適應
                            //自動展開,
                            e.expand();
                            this.doQuery(this.allQuery, true);

                            //把下拉框展開後的列表部分設為寬度自適應
                            var t_list_id = e.picker.el.el.id;
                            $('#' + t_list_id).css('width', 'auto');
                            $('#' + t_list_id).css('minWidth', '120px');
                        },
                        buffer: 100
                    }
                }
            });
            return editor;
        }

               >>>