extjs多选下拉框
类别:Web前端 浏览量:3904
时间:2014-5-6 extjs多选下拉框
extjs多选下拉框一、用LovCombo。js插件实现
LovCombo脚本文件
// vim: ts=4:sw=4:nu:fdc=4:nospell
/**
* Ext.ux.form.LovCombo, List of Values Combo
*
* @author Ing. Jozef Sakáloš
* @copyright (c) 2008, by Ing. Jozef Sakáloš
* @date 16. April 2008
* @version $Id: Ext.ux.form.LovCombo.js 285 2008-06-06 09:22:20Z jozo $
*
* @license Ext.ux.form.LovCombo.js is licensed under the terms of the Open Source
* LGPL 3.0 license. Commercial use is permitted to the extent that the
* code/component(s) do NOT become part of another Open Source or Commercially
* licensed development library or toolkit without explicit permission.
*
* License details: http://www.gnu.org/licenses/lgpl.html
*/
/*global Ext */
// add RegExp.escape if it has not been already added
if ('function' !== typeof RegExp.escape) {
RegExp.escape = function(s) {
if ('string' !== typeof s) {
return s;
}
// Note: if pasting from forum, precede ]// with backslash manually
return s.replace(/([.*+?^=!:${}()|[/]////])/g, '//$1');
}; // eo function escape
}
// create namespace
Ext.ns('Ext.ux.form');
/**
*
* @class Ext.ux.form.LovCombo
* @extends Ext.form.ComboBox
*/
Ext.ux.form.LovCombo = Ext.extend(Ext.form.ComboBox, {
// {{{
// configuration options
/**
* @cfg {String} selectAllOn the value of the option used as
* the select-all / deselect-all trigger
*/
selectAllOn: null,
/**
* @cfg {String} checkField name of field used to store checked state.
* It is automatically added to existing fields.
* Change it only if it collides with your normal field.
*/
checkField: 'checked'
/**
* @cfg {String} separator separator to use between values and texts for getValue and submission
*/
, separator: ','
/**
* @cfg {String} displaySeparator displaySeparator to use between values and texts for display
*/
, displaySeparator: ','
/**
* @cfg {String/Array} tpl Template for items.
* Change it only if you know what you are doing.
*/
// }}}
// {{{
, initComponent: function() {
// template with checkbox
if (!this.tpl) {
this.tpl =
'<tpl for=".">'
+ '<li class="x-combo-list-item">'
+ '<img src="' + Ext.BLANK_IMAGE_URL + '" mce_src="' + Ext.BLANK_IMAGE_URL + '" '
+ 'class="ux-lovcombo-icon ux-lovcombo-icon-'
//+'{[values.' + this.checkField + '?"checked":values.' + this.checkField + '===null?"mixed":"unchecked"' + ']}">'
+ '{[values.' + this.checkField + '?"checked":"unchecked"' + ']}">'
+ '<li class="ux-lovcombo-item-text">{' + (this.displayField || 'text') + '}</li>'
+ '</li>'
+ '</tpl>'
;
}
// call parent
Ext.ux.form.LovCombo.superclass.initComponent.apply(this, arguments);
// install internal event handlers
this.on({
scope: this
, beforequery: this.onBeforeQuery
//,blur:this.onRealBlur
});
// remove selection from input field
this.onLoad = this.onLoad.createSequence(function() {
if (this.el) {
var v = this.el.dom.value;
this.el.dom.value = '';
this.el.dom.value = v;
}
});
} // e/o function initComponent
// }}}
// {{{
/**
* Disables default tab key bahavior
* @private
*/
, initEvents: function() {
Ext.ux.form.LovCombo.superclass.initEvents.apply(this, arguments);
// disable default tab handling - does no good
this.keyNav.tab = false;
} // eo function initEvents
// }}}
// {{{
/**
* clears value
*/
, clearValue: function() {
this.value = '';
this.setRawValue(this.value);
this.store.clearFilter();
this.store.each(function(r) {
r.set(this.checkField, false);
}, this);
if (this.hiddenField) {
this.hiddenField.value = '';
}
this.applyEmptyText();
} // eo function clearValue
// }}}
// {{{
/**
* @return {String} separator (plus space) separated list of selected displayFields
* @private
*/
, getCheckedDisplay: function() {
var re = new RegExp(RegExp.escape(this.separator), "g");
return this.getCheckedValue(this.displayField).replace(re, RegExp.escape(this.displaySeparator) + ' ');
} // eo function getCheckedDisplay
// }}}
// {{{
/**
* @return {String} separator separated list of selected valueFields
* @private
*/
, getCheckedValue: function(field) {
field = field || this.valueField;
var c = [];
// store may be filtered so get all records
var snapshot = this.store.snapshot || this.store.data;
snapshot.each(function(r)
您可能感兴趣
- Extjs中FieldSet的收缩和展开
- extjs table布局
- extjs中apply和applyIf的用法
- extjs accordion折叠布局
- extjs anchor 锚点布局
- extjs XTemplate的实例
- Extjs menu菜单的简单用法
- extjs Border边框布局
- extjs中treepanel属性和方法
- extjs column列布局
- ExtJs 中Viewport 的使用
- Extjs updateProgress进度条的应用
- ExtJs中Store的种类
- Extjs中grid 的ColumnModel 属性配置
- extjs 日期控件
- extjs checkboxGroup 复选框的用法
- 九儿《狐踪谍影》出演热血女特警,戏份杀青受关注(九儿狐踪谍影出演热血女特警)
- 红色代表什么(红色代表什么寓意)
- 蓝天代表什么(蓝天代表什么生肖)
- 今天要吃什么(今天要吃什么菜)
- 营养餐是什么(学校营养餐是什么)
- 谁说女子不如男 范冰冰演的武则天只是其一,另外两位你认识吗(谁说女子不如男)
热门推荐
- 如何用python处理excel表格(零基础使用Python读写处理Excel表格的方法)
- 动态加载js脚本
- 织梦各个模板对应的页面(织梦DEDECMS实现留言板调用模板头部及底部的方法)
- tomcat架构结构图(Tomcat核心组件及应用架构详解)
- dedecms简介(Linux操作系统下DedeCMS详细安全设置教程)
- flashfxp使用视频教程(FlashFXP 命令行参数)
- vue 单文件组件(vue实现一个单文件组件的完整过程记录)
- canvas如何将一组数据生成柱子图(Canvas环形饼图与手势控制的实现代码)
- python随机生成时间戳(python时间序列按频率生成日期的方法)
- 腾讯云服务器初始化操作(腾讯云服务器入门使用流程[新手必看教程])