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 xtype的使用
- extjs 日期控件
- extjs XTemplate的实例
- extjs radiogroup赋值和取值
- Extjs msgTarget 提示位置
- ExtJs 中Viewport 的使用
- Extjs中文乱码
- extjs checkboxGroup 复选框的用法
- ExtJs中怎么上传文件
- extjs中Toolbar工具栏
- extjs中treegrid
- ExtJs中Store的种类
- extjs中treepanel例子
- extjs中apply和applyIf的用法
- extjs实现树形下拉框
- extjs多选下拉框
- 哪几个历史人物被影协主席李雪健演的活灵活现(哪几个历史人物被影协主席李雪健演的活灵活现)
- 王伦狭隘,晁盖霸道,宋江奸诈骨头软,只有鲁智深才适合当寨主(王伦狭隘晁盖霸道)
- 他是梁山最早的头目,江湖人称 旱地忽律 ,宋江几乎将其遗忘(他是梁山最早的头目)
- 梁山创始人杜迁,为何不受宋江待见,只排名83位(梁山创始人杜迁)
- 法国面包(法国面包法棍)
- 微信(微信分身)
热门推荐
- vs远程调试
- docker容器是怎么进行通信的(Docker容器间通信与外网通信的操作)
- 个人云服务器的搭建(云服务器管理怎么做?这几款开源服务器管理软件您得知道)
- python创建pdf(Python玩转PDF的各种骚操作)
- python中的insert(python assert的用处示例详解)
- dedecms权限调整(增加dedecms后台留言管理功能)
- springboot怎么设置docker(Docker如何给Springboot项目动态传参的实现方法)
- laravel怎样封装增删改查(laravel框架上传图片实现实时预览功能)
- 百度地图获取api过程(JavaScript接入百度地图API的方法步骤)
- pythontkinter详解(python3.6使用tkinter实现弹跳小球游戏)