读书人

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

发布时间: 2012-10-08 19:54:56 作者: rapoo

带复选框且支持搜索功能的下拉列表7

// private    onSelect : function(record, index)    {        /*         * 增加一个全选功能,ckf36476         */        if (index == 0)        {            var r_qx = this.store.getAt(index);            var newValue_qx = r_qx.data[this.displayField];            var check_qx = document.getElementById("checkBox_" + newValue_qx);            if (check_qx.className == "checked")            {                check_qx.className = "unchecked"            }            else            {                check_qx.className = "checked"            }            for (var i = 1; i < this.store.data.length; i++)            {                var r = this.store.getAt(i);                var newValue = r.data[this.displayField];                var check = document.getElementById("checkBox_" + newValue);                if (check_qx.className == "checked")                {                    check.className = "checked"                }                else                {                    check.className = "unchecked"                }            }            var value = "";            var hiddenValue = "";            for (var i = 0; i < this.store.data.length; i++)            {                var r = this.store.getAt(i);                newValue = r.data[this.displayField];                check = document.getElementById("checkBox_" + newValue);                if (check.className == "checked")                {                    value += r.data[this.displayField] + this.displaySeparator;                    hiddenValue += r.data[this.valueField] + this.valueSeparator;                }            }            if (value.length > 1)            {                value = value.substring(0, value.length - this.displaySeparator.length);            }            if (hiddenValue.length > 1)            {                hiddenValue = hiddenValue.substring(0, value.length - this.valueSeparator.length);            }            this.setValue(value);            this.hiddenField.value = hiddenValue;            this.fireEvent('select', this, record, index);            return;        }        //全选结束        if (this.fireEvent('beforeselect', this, record, index) !== false)        {            var r = this.store.getAt(index);            var newValue = r.data[this.displayField];            var check = document.getElementById("checkBox_" + newValue);            if (check.className == "checked")            {                check.className = "unchecked"            }            else            {                check.className = "checked"            }            var value = "";            var hiddenValue = "";            for (var i = 0; i < this.store.data.length; i++)            {                var r = this.store.getAt(i);                newValue = r.data[this.displayField];                check = document.getElementById("checkBox_" + newValue);                if (check.className == "checked")                {                    value += r.data[this.displayField] + this.displaySeparator;                    hiddenValue += r.data[this.valueField] + this.valueSeparator;                }            }            if (value.length > 1)            {                value = value.substring(0, value.length - this.displaySeparator.length);            }            if (hiddenValue.length > 1)            {                hiddenValue = hiddenValue.substring(0, value.length - this.valueSeparator.length);            }            this.setValue(value);            this.hiddenField.value = hiddenValue;            this.fireEvent('select', this, record, index);        }    },

读书人网 >Web前端

热点推荐