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 column列布局
- ExtJs中getCmp、getDom、Get的区别
- extjs中apply和applyIf的用法
- extjs实现树形下拉框
- ExtJs中Store的种类
- extjs accordion折叠布局
- extjs xtype的使用
- extjs tabPanel的用法
- extjs table布局
- ExtJs中XTemplate使用
- extjs XTemplate的实例
- Extjs中文乱码
- ExtJs中怎么上传文件
- extjs card卡片式布局
- Extjs msgTarget 提示位置
- ExtJs常用代码片段
- 小米推出米兔儿童电话手表奥特曼版,799 元,支持微信 QQ(小米推出米兔儿童电话手表奥特曼版)
- 贾怀胤唱《白龙马》 炸场 了 没想到京剧还能这么玩(贾怀胤唱白龙马)
- 白龙马的改编学生版,快来看看(白龙马的改编学生版)
- 萌娃唱《白龙马》走红,那生动的小表情,网友直呼 简直是戏精(萌娃唱白龙马走红)
- 朱鹤松被不断认可,凤凰传奇玲花喊话岳云鹏,索要老朱演出门票(朱鹤松被不断认可)
- 元宵晚会槽点多,芒果台上来就假唱,岳云鹏不说相声改评书了(元宵晚会槽点多)
热门推荐
- input的autocomplete="off"属性
- centos linux开机不出现登录页面(在CentOS启动时自动加载内核模块overlayfs操作)
- dedecms如何提高网站权重(dede网站内容页如何调取栏目页标题及关键字组合为seo标题)
- 织梦仿站流程图解(织梦sitemap地图实时推送给百度的教程)
- django响应返回的常用方法(Django异步任务之Celery的基本使用)
- pythonsocket编写web服务器(局域网内python socket实现windows与linux间的消息传送)
- 10款免费好用的云服务器/VPS主机控制面板推荐(10款免费好用的云服务器/VPS主机控制面板推荐)
- web压力测试工具app(十款Web服务器性能压力测试工具)
- mysql全套优化(Mysql优化神器推荐)
- 用javascript解析json(JavaScript JSON.stringify的使用总结)