当前位置: 代码迷 >> Web前端 >> 带复选框且支持搜索功能的上拉列表8
  详细解决方案

带复选框且支持搜索功能的上拉列表8

热度:86   发布时间:2012-10-06 17:34:01.0
带复选框且支持搜索功能的下拉列表8
getValue : function()
    {
        if (this.valueField)
        {
            return typeof this.value != 'undefined' ? this.value : '';
        }
        else
        {
            return Ext.form.ComboBox.superclass.getValue.call(this);
        }
    },

    /**
     * Clears any text/value currently set in the field
     */
    clearValue : function()
    {
        if (this.hiddenField)
        {
            this.hiddenField.value = '';
        }
        this.setRawValue('');
        this.lastSelectionText = '';
        this.applyEmptyText();
    },
    setValue : function(v)
    {
        var text = v;
        if (this.valueField)
        {
            var r = this.findRecord(this.valueField, v);
            if (r)
            {
                text = r.data[this.displayField];
            } else if (this.valueNotFoundText !== undefined)
            {
                text = this.valueNotFoundText;
            }
        }
        this.lastSelectionText = text;
        Ext.form.ComboBox.superclass.setValue.call(this, text);
        this.value = v;
    },
    /*-----zKF36477 处理下拉多选框赋值操作,批量选中编写的扩展方法 start-----*/
    setValues_array : function(v)
    {
        var text = "";
        this.initList();
        var vv = null != v ? v.split(",") : "";
        for (var i = 0; i < vv.length; i++)
        {
            if (this.valueField)
            {
                var r = this.findRecord(this.valueField, vv[i]);
                if (r)
                {
                    var check = document.getElementById("checkBox_" + r.data[this.displayField]);

                    if (null != check && check != undefined && check != "")
                    {
                        if (text == "")
                        {
                            text += r.data[this.displayField];
                        }
                        else
                        {
                            text += "," + r.data[this.displayField];
                        }

                        if (check.className == "checked")
                        {
                            check.className = "checked"
                        }
                        else
                        {
                            check.className = "checked"
                        }
                    }
                } else if (this.valueNotFoundText !== undefined)
                {
                    if (text == "")
                    {
                        text += this.valueNotFoundText;
                    }
                    else
                    {
                        text += "," + this.valueNotFoundText;
                    }
                }
            }
        }
        this.lastSelectionText = text;
        Ext.form.ComboBox.superclass.setValue.call(this, text);
        this.value = text;
    },
    /*-----zKF36477 处理下拉多选框赋值操作,批量选中编写的扩展方法 end-----*/"]
  相关解决方案