MultiComboBox

Ext2.0下拉多選菜單(MultiComboBox)

由於Ext2.0的ComboBox不支持菜單多選,本人花了點時間通過擴展ComboBox功能支持下拉多選功能的MultiComboBox。下面介紹MultiComboBox的使用方式,大家先看看下面的代碼:

Java代碼
  1. Ext .onReady(function(){  
  2.           var formPanel = new  Ext .FormPanel({  
  3.             height : 100 , // 表單面板的高度   
  4.             width : 400 , // 表單面板的寬度   
  5.             labelWidth : 120 , // 字段標籤寬度   
  6.             labelAlign : "right" , // 字段標籤對齊方式   
  7.             fileUpload: true , //支持文件上傳   
  8.             defaults : {// 默認form元素類型爲textfield   
  9.                 xtype : "textfield" , // 默認類型爲textfield   
  10.                 width : 150   // 默認寬度   
  11.             },  
  12.             items : [{  
  13.                xtype:'multicombo' ,  
  14.                width:250 ,  
  15.                store: new  Ext .data.SimpleStore({  
  16.                    fields: ["name" , "value" ],  
  17.                    data:[['測試菜單1' , 1 ],[ '測試菜單2' , 2 ],[ '測試菜單3' , 3 ],[ '測試菜單4' , 4 ]]}),  
  18.                valueField :"value" ,  
  19.                displayField: "name" ,  
  20.                labelSeparator:':' ,  
  21.                displaySeparator:';' ,  
  22.                valueSeparator:',' ,  
  23.                mode: 'local' ,  
  24.                value:'1,2' ,  
  25.                forceSelection: true ,  
  26.                hiddenName:'test' ,  
  27.                editable: true ,  
  28.                triggerAction: 'all' ,  
  29.                allowBlank:false ,  
  30.                emptyText:'請選擇' ,  
  31.                fieldLabel: '多選下拉ComBo'   
  32.             }],       
  33.             buttons : [{  
  34.                 text : '提交' ,  
  35.                 type : 'submit' ,  
  36.                 handler : function() {  
  37.                       
  38.                 }  
  39.             }]  
  40.         });  
  41.         formPanel.render("multicombo-div" );  
  42. });  
Ext
.onReady(function(){
   	  	  var formPanel = new Ext
.FormPanel({
			height : 100,// 表單面板的高度
			width : 400,// 表單面板的寬度
			labelWidth : 120,// 字段標籤寬度
			labelAlign : "right",// 字段標籤對齊方式
			fileUpload: true,//支持文件上傳
			defaults : {// 默認form元素類型爲textfield
				xtype : "textfield",// 默認類型爲textfield
				width : 150 // 默認寬度
			},
			items : [{
			   xtype:'multicombo',
			   width:250,
			   store: new Ext
.data.SimpleStore({
			       fields: ["name","value"],
			       data:[['測試菜單1',1],['測試菜單2',2],['測試菜單3',3],['測試菜單4',4]]}),
			   valueField :"value",
			   displayField: "name",
			   labelSeparator:':',
			   displaySeparator:';',
			   valueSeparator:',',
			   mode: 'local',
			   value:'1,2',
			   forceSelection: true,
			   hiddenName:'test',
			   editable: true,
			   triggerAction: 'all',
			   allowBlank:false,
			   emptyText:'請選擇',
			   fieldLabel: '多選下拉ComBo'
			}],		
			buttons : [{
				text : '提交',
				type : 'submit',
				handler : function() {
					
				}
			}]
		});
		formPanel.render("multicombo-div");
});


由上面代碼可以看到用法大致和ComboBox一樣,不相同的地方是:
Java代碼
  1. xtype: 'multicombo' , //MultiComboBox註冊類型名稱   
  2. displaySeparator:';' , //多選顯示分隔字符   
  3. valueSeparator:',' , //多選提交到後臺的值分隔符   
  4. value:'1,2' , //  多值通過","分隔,與valueSeparator相對應,表示默認選擇了"測試菜單1'"和"測試菜單2"   
xtype:'multicombo',//MultiComboBox註冊類型名稱
displaySeparator:';',//多選顯示分隔字符
valueSeparator:',',//多選提交到後臺的值分隔符
value:'1,2',//  多值通過","分隔,與valueSeparator相對應,表示默認選擇了"測試菜單1'"和"測試菜單2"


由於添加了多選CheckBox圖標,所以需要在ext -all.css文件最後添加兩行支持樣式:
Java代碼
  1. .checked{background-image:url(../images/ default /menu/checked.gif)}  
  2. .unchecked{background-image:url(../images/default /menu/unchecked.gif)}  
.checked{background-image:url(../images/default/menu/checked.gif)}
.unchecked{background-image:url(../images/default/menu/unchecked.gif)}


MultiComboBox的源代碼:
Java代碼
  1. Ext .form.MultiComboBox = Ext .extend(Ext .form.TriggerField, {  
  2.     defaultAutoCreate : {tag: "input" , type:  "text" , size:  "24" , autocomplete:  "off" },  
  3.     listClass: '' ,  
  4.     selectedClass: 'x-combo-selected' ,  
  5.     triggerClass : 'x-form-arrow-trigger' ,  
  6.     shadow:'sides' ,  
  7.     listAlign: 'tl-bl?' ,  
  8.     maxHeight: 300 ,  
  9.     triggerAction: 'query' ,  
  10.     minChars : 4 ,  
  11.     typeAhead: false ,  
  12.     queryDelay: 500 ,  
  13.     pageSize: 0 ,  
  14.     selectOnFocus:false ,  
  15.     queryParam: 'query' ,  
  16.     loadingText: 'Loading...' ,  
  17.     resizable: false ,  
  18.     handleHeight : 8 ,  
  19.     editable: true ,  
  20.     allQuery: '' ,  
  21.     mode: 'remote' ,  
  22.     minListWidth : 70 ,  
  23.     forceSelection:false ,  
  24.     typeAheadDelay : 250 ,  
  25.     displaySeparator:';' ,  
  26.     valueSeparator:',' ,  
  27.     lazyInit : true ,  
  28.   
  29.     initComponent : function(){  
  30.         Ext .form.ComboBox.superclass.initComponent.call(this );  
  31.         this .addEvents(  
  32.             'expand' ,  
  33.             'collapse' ,  
  34.             'beforeselect' ,  
  35.             'select' ,  
  36.             'beforequery'   
  37.         );  
  38.         if ( this .transform){  
  39.             this .allowDomMove =  false ;  
  40.             var s = Ext .getDom(this .transform);  
  41.             if (! this .hiddenName){  
  42.                 this .hiddenName = s.name;  
  43.             }  
  44.             if (! this .store){  
  45.                 this .mode =  'local' ;  
  46.                 var d = [], opts = s.options;  
  47.                 for (var i =  0 , len = opts.length;i < len; i++){  
  48.                     var o = opts[i];  
  49.                     var value = (Ext .isIE ? o.getAttributeNode('value' ).specified : o.hasAttribute( 'value' )) ? o.value : o.text;  
  50.                     if (o.selected) {  
  51.                         this .value = value;  
  52.                     }  
  53.                     d.push([value, o.text]);  
  54.                 }  
  55.                 this .store =  new  Ext .data.SimpleStore({  
  56.                     'id' 0 ,  
  57.                     fields: ['value' 'text' ],  
  58.                     data : d  
  59.                 });  
  60.                 this .valueField =  'value' ;  
  61.                 this .displayField =  'text' ;  
  62.             }  
  63.             s.name = Ext .id(); // wipe out the name in case somewhere else they have a reference   
  64.             if (! this .lazyRender){  
  65.                 this .target =  true ;  
  66.                 this .el = Ext .DomHelper.insertBefore(s,  this .autoCreate ||  this .defaultAutoCreate);  
  67.                 Ext .removeNode(s); // remove it   
  68.                 this .render( this .el.parentNode);  
  69.             }else {  
  70.                 Ext .removeNode(s); // remove it   
  71.             }  
  72.   
  73.         }  
  74.         this .selectedIndex = - 1 ;  
  75.         if ( this .mode ==  'local' ){  
  76.             if ( this .initialConfig.queryDelay === undefined){  
  77.                 this .queryDelay =  10 ;  
  78.             }  
  79.             if ( this .initialConfig.minChars === undefined){  
  80.                 this .minChars =  0 ;  
  81.             }  
  82.         }  
  83.     },  
  84.   
  85.     // private   
  86.     onRender : function(ct, position){  
  87.         Ext .form.ComboBox.superclass.onRender.call(this , ct, position);  
  88.         var disValue="" ;  
  89.         if ( this .hiddenName){  
  90.             this .hiddenField =  this .el.insertSibling({tag: 'input' , type: 'hidden' , name:  this .hiddenName, id: ( this .hiddenId|| this .hiddenName)},  
  91.                     'before' true );  
  92.           var hvalue=this .hiddenValue !== undefined ?  this .hiddenValue :  
  93.                 this .value !== undefined ?  this .value :  '' ;  
  94.           var hvalueArray=hvalue.split(this .valueSeparator);  
  95.             
  96.           for (var i= 0 ;i< this .store.data.length;i++){  
  97.                  var r = this .store.getAt(i);     
  98.                  var newValue = r.data[this .displayField];  
  99.                   var v=r.data[this .valueField];  
  100.                   for (var j= 0 ;j<hvalueArray.length;j++){  
  101.                     if (hvalueArray[j]==v){  
  102.                         disValue+=newValue+this .displaySeparator;  
  103.                     }  
  104.                   }  
  105.                    
  106.           }       
  107.             this .hiddenField.value = this .hiddenValue !== undefined ?  this .hiddenValue :  
  108.                 this .value !== undefined ?  this .value :  '' ;  
  109.             this .el.dom.removeAttribute( 'name' );  
  110.         }  
  111.         if (Ext .isGecko){  
  112.             this .el.dom.setAttribute( 'autocomplete' 'off' );  
  113.         }  
  114.   
  115.         if (! this .lazyInit){  
  116.             this .initList();  
  117.         }else {  
  118.             this .on( 'focus' this .initList,  this , {single:  true });  
  119.         }  
  120.   
  121.         if (! this .editable){  
  122.             this .editable =  true ;  
  123.             this .setEditable( false );  
  124.         }  
  125.         this .setValue(disValue);  
  126.     },  
  127.   
  128.     initList : function(){  
  129.         if (! this .list){  
  130.             var cls = 'x-combo-list' ;  
  131.   
  132.             this .list =  new  Ext .Layer({  
  133.                 shadow: this .shadow, cls: [cls,  this .listClass].join( ' ' ), constrain: false   
  134.             });  
  135.   
  136.             var lw = this .listWidth || Math.max( this .wrap.getWidth(),  this .minListWidth);  
  137.             this .list.setWidth(lw);  
  138.             this .list.swallowEvent( 'mousewheel' );  
  139.             this .assetHeight =  0 ;  
  140.   
  141.             if ( this .title){  
  142.                 this .header =  this .list.createChild({cls:cls+ '-hd' , html:  this .title});  
  143.                 this .assetHeight +=  this .header.getHeight();  
  144.             }  
  145.   
  146.             this .innerList =  this .list.createChild({cls:cls+ '-inner' });  
  147.             this .innerList.on( 'mouseover' this .onViewOver,  this );  
  148.             this .innerList.on( 'mousemove' this .onViewMove,  this );  
  149.             this .innerList.setWidth(lw -  this .list.getFrameWidth( 'lr' ))  
  150.   
  151.             if ( this .pageSize){  
  152.                 this .footer =  this .list.createChild({cls:cls+ '-ft' });  
  153.                 this .pageTb =  new  Ext .PagingToolbar({  
  154.                     store:this .store,  
  155.                     pageSize: this .pageSize,  
  156.                     renderTo:this .footer  
  157.                 });  
  158.                 this .assetHeight +=  this .footer.getHeight();  
  159.             }  
  160.   
  161.             if (! this .tpl){  
  162.                 //alert(cls);   
  163.                 //x-combo-list-item   
  164.                 this .tpl =  '<tpl for="."><div class="' +cls+ '-item"><span class="unchecked" id="checkBox_{'  +  this .displayField +  '}"+ width="20">&nbsp;&nbsp;&nbsp;&nbsp;</span>{'  +  this .displayField +  '}</div></tpl>' ;  
  165.             }  
  166.             this .view =  new  Ext .DataView({  
  167.                 applyTo: this .innerList,  
  168.                 tpl: this .tpl,  
  169.                 singleSelect: true ,  
  170.                 selectedClass: this .selectedClass,  
  171.                 itemSelector: this .itemSelector ||  '.'  + cls +  '-item'   
  172.             });  
  173.   
  174.             this .view.on( 'click' this .onViewClick,  this );  
  175.   
  176.             this .bindStore( this .store,  true );  
  177.   
  178.             if ( this .resizable){  
  179.                 this .resizer =  new  Ext .Resizable( this .list,  {  
  180.                    pinned:true , handles: 'se'   
  181.                 });  
  182.                 this .resizer.on( 'resize' , function(r, w, h){  
  183.                     this .maxHeight = h- this .handleHeight- this .list.getFrameWidth( 'tb' )- this .assetHeight;  
  184.                     this .listWidth = w;  
  185.                     this .innerList.setWidth(w -  this .list.getFrameWidth( 'lr' ));  
  186.                     this .restrictHeight();  
  187.                 }, this );  
  188.                 this [ this .pageSize? 'footer' : 'innerList' ].setStyle( 'margin-bottom' this .handleHeight+ 'px' );  
  189.             }  
  190.         }  
  191.     },  
  192.   
  193.     bindStore : function(store, initial){  
  194.         if ( this .store && !initial){  
  195.             this .store.un( 'beforeload' this .onBeforeLoad,  this );  
  196.             this .store.un( 'load' this .onLoad,  this );  
  197.             this .store.un( 'loadexception' this .collapse,  this );  
  198.             if (!store){  
  199.                 this .store =  null ;  
  200.                 if ( this .view){  
  201.                     this .view.setStore( null );  
  202.                 }  
  203.             }  
  204.         }  
  205.         if (store){  
  206.             this .store = Ext .StoreMgr.lookup(store);  
  207.   
  208.             this .store.on( 'beforeload' this .onBeforeLoad,  this );  
  209.             this .store.on( 'load' this .onLoad,  this );  
  210.             this .store.on( 'loadexception' this .collapse,  this );  
  211.   
  212.             if ( this .view){  
  213.                 this .view.setStore(store);  
  214.             }  
  215.         }  
  216.     },  
  217.   
  218.     // private   
  219.     initEvents : function(){  
  220.         Ext .form.ComboBox.superclass.initEvents.call(this );  
  221.   
  222.         this .keyNav =  new  Ext .KeyNav( this .el, {  
  223.             "up"  : function(e){  
  224.                 this .inKeyMode =  true ;  
  225.                 this .selectPrev();  
  226.             },  
  227.   
  228.             "down"  : function(e){  
  229.                 if (! this .isExpanded()){  
  230.                     this .onTriggerClick();  
  231.                 }else {  
  232.                     this .inKeyMode =  true ;  
  233.                     this .selectNext();  
  234.                 }  
  235.             },  
  236.   
  237.             "enter"  : function(e){  
  238.                 this .onViewClick();  
  239.                 //return true;   
  240.             },  
  241.   
  242.             "esc"  : function(e){  
  243.                 this .collapse();  
  244.             },  
  245.   
  246.             "tab"  : function(e){  
  247.                 this .onViewClick( false );  
  248.                 return   true ;  
  249.             },  
  250.   
  251.             scope : this ,  
  252.   
  253.             doRelay : function(foo, bar, hname){  
  254.                 if (hname ==  'down'  ||  this .scope.isExpanded()){  
  255.                    return  Ext .KeyNav.prototype.doRelay.apply( this , arguments);  
  256.                 }  
  257.                 return   true ;  
  258.             },  
  259.   
  260.             forceKeyDown : true   
  261.         });  
  262.         this .queryDelay = Math.max( this .queryDelay ||  10 ,  
  263.                 this .mode ==  'local'  ?  10  :  250 );  
  264.         this .dqTask =  new  Ext .util.DelayedTask( this .initQuery,  this );  
  265.         if ( this .typeAhead){  
  266.             this .taTask =  new  Ext .util.DelayedTask( this .onTypeAhead,  this );  
  267.         }  
  268.         if ( this .editable !==  false ){  
  269.             this .el.on( "keyup" this .onKeyUp,  this );  
  270.         }  
  271.         if ( this .forceSelection){  
  272.             this .on( 'blur' this .doForce,  this );  
  273.         }  
  274.     },  
  275.   
  276.     onDestroy : function(){  
  277.         if ( this .view){  
  278.             this .view.el.removeAllListeners();  
  279.             this .view.el.remove();  
  280.             this .view.purgeListeners();  
  281.         }  
  282.         if ( this .list){  
  283.             this .list.destroy();  
  284.         }  
  285.         this .bindStore( null );  
  286.         Ext .form.ComboBox.superclass.onDestroy.call(this );  
  287.     },  
  288.   
  289.     // private   
  290.     fireKey : function(e){  
  291.         if (e.isNavKeyPress() && ! this .list.isVisible()){  
  292.             this .fireEvent( "specialkey" this , e);  
  293.         }  
  294.     },  
  295.   
  296.     // private   
  297.     onResize: function(w, h){  
  298.         Ext .form.ComboBox.superclass.onResize.apply(this , arguments);  
  299.         if ( this .list &&  this .listWidth === undefined){  
  300.             var lw = Math.max(w, this .minListWidth);  
  301.             this .list.setWidth(lw);  
  302.             this .innerList.setWidth(lw -  this .list.getFrameWidth( 'lr' ));  
  303.         }  
  304.     },  
  305.   
  306.     // private   
  307.     onDisable: function(){  
  308.         Ext .form.ComboBox.superclass.onDisable.apply(this , arguments);  
  309.         if ( this .hiddenField){  
  310.             this .hiddenField.disabled =  this .disabled;  
  311.         }  
  312.     },  
  313.     setEditable : function(value){  
  314.         if (value ==  this .editable){  
  315.             return ;  
  316.         }  
  317.         this .editable = value;  
  318.         if (!value){  
  319.             this .el.dom.setAttribute( 'readOnly' true );  
  320.             this .el.on( 'mousedown' this .onTriggerClick,   this );  
  321.             this .el.addClass( 'x-combo-noedit' );  
  322.         }else {  
  323.             this .el.dom.setAttribute( 'readOnly' false );  
  324.             this .el.un( 'mousedown' this .onTriggerClick,   this );  
  325.             this .el.removeClass( 'x-combo-noedit' );  
  326.         }  
  327.     },  
  328.   
  329.     // private   
  330.     onBeforeLoad : function(){  
  331.         if (! this .hasFocus){  
  332.             return ;  
  333.         }  
  334.         this .innerList.update( this .loadingText ?  
  335.                '<div class="loading-indicator">' + this .loadingText+ '</div>'  :  '' );  
  336.         this .restrictHeight();  
  337.         this .selectedIndex = - 1 ;  
  338.     },  
  339.   
  340.     // private   
  341.     onLoad : function(){  
  342.         if (! this .hasFocus){  
  343.             return ;  
  344.         }  
  345.         if ( this .store.getCount() >  0 ){  
  346.             this .expand();  
  347.             this .restrictHeight();  
  348.             if ( this .lastQuery ==  this .allQuery){  
  349.                 if ( this .editable){  
  350.                     this .el.dom.select();  
  351.                 }  
  352.                 if (! this .selectByValue( this .value,  true )){  
  353.                     this .select( 0 true );  
  354.                 }  
  355.             }else {  
  356.                 this .selectNext();  
  357.                 if ( this .typeAhead &&  this .lastKey != Ext .EventObject.BACKSPACE &&  this .lastKey != Ext .EventObject.DELETE){  
  358.                     this .taTask.delay( this .typeAheadDelay);  
  359.                 }  
  360.             }  
  361.         }else {  
  362.             this .onEmptyResults();  
  363.         }  
  364.     },  
  365.   
  366.     // private   
  367.     onTypeAhead : function(){  
  368.         if ( this .store.getCount() >  0 ){  
  369.             var r = this .store.getAt( 0 );  
  370.             var newValue = r.data[this .displayField];  
  371.             var len = newValue.length;  
  372.             var selStart = this .getRawValue().length;  
  373.             if (selStart != len){  
  374.                 this .setRawValue(newValue);  
  375.                 this .selectText(selStart, newValue.length);  
  376.             }  
  377.         }  
  378.     },  
  379.     // private   
  380.     onSelect : function(record, index){  
  381.         if ( this .fireEvent( 'beforeselect' this , record, index) !==  false ){  
  382.             var r = this .store.getAt(index);  
  383.             var newValue = r.data[this .displayField];  
  384.             var check=document.getElementById("checkBox_" +newValue);  
  385.             if (check.className== "checked" ){  
  386.                 check.className="unchecked"   
  387.             }else {  
  388.                 check.className="checked"   
  389.             }  
  390.             var value="" ;   
  391.             var hiddenValue="" ;  
  392.             for (var i= 0 ;i< this .store.data.length;i++){  
  393.                  var r = this .store.getAt(i);     
  394.                  newValue = r.data[this .displayField];  
  395.                  check=document.getElementById("checkBox_" +newValue);  
  396.                  if (check.className== "checked" ){  
  397.                     value+= r.data[this .displayField]+ this .displaySeparator;  
  398.                     hiddenValue+= r.data[this .valueField]+ this .valueSeparator;  
  399.                  }  
  400.             }  
  401.             if (value.length> 1 ){  
  402.                 value=value.substring(0 ,value.length- this .displaySeparator.length);  
  403.             }  
  404.             if (hiddenValue.length> 1 ){  
  405.                 hiddenValue=hiddenValue.substring(0 ,value.length- this .valueSeparator.length);  
  406.             }  
  407.             this .setValue(value);  
  408.             this .hiddenField.value=hiddenValue;  
  409.             this .fireEvent( 'select' this , record, index);  
  410.         }  
  411.     },  
  412.     getValue : function(){  
  413.         if ( this .valueField){  
  414.             return  typeof  this .value !=  'undefined'  ?  this .value :  '' ;  
  415.         }else {  
  416.             return  Ext .form.ComboBox.superclass.getValue.call( this );  
  417.         }  
  418.     },  
  419.   
  420.     /**  
  421.      * Clears any text/value currently set in the field  
  422.      */   
  423.     clearValue : function(){  
  424.         if ( this .hiddenField){  
  425.             this .hiddenField.value =  '' ;  
  426.         }  
  427.         this .setRawValue( '' );  
  428.         this .lastSelectionText =  '' ;  
  429.         this .applyEmptyText();  
  430.     },  
  431.     setValue : function(v){  
  432.         var text = v;  
  433.         if ( this .valueField){  
  434.             var r = this .findRecord( this .valueField, v);  
  435.             if (r){  
  436.                 text = r.data[this .displayField];  
  437.             }else   if ( this .valueNotFoundText !== undefined){  
  438.                 text = this .valueNotFoundText;  
  439.             }  
  440.         }  
  441.         this .lastSelectionText = text;  
  442.         Ext .form.ComboBox.superclass.setValue.call(this , text);  
  443.         this .value = v;  
  444.     },  
  445.   
  446.     // private   
  447.     findRecord : function(prop, value){  
  448.         var record;  
  449.         if ( this .store.getCount() >  0 ){  
  450.             this .store.each(function(r){  
  451.                 if (r.data[prop] == value){  
  452.                     record = r;  
  453.                     return   false ;  
  454.                 }  
  455.             });  
  456.         }  
  457.         return  record;  
  458.     },  
  459.   
  460.     // private   
  461.     onViewMove : function(e, t){  
  462.         this .inKeyMode =  false ;  
  463.     },  
  464.   
  465.     // private   
  466.     onViewOver : function(e, t){  
  467.         if ( this .inKeyMode){  // prevent key nav and mouse over conflicts   
  468.             return ;  
  469.         }  
  470.         var item = this .view.findItemFromChild(t);  
  471.         if (item){  
  472.             var index = this .view.indexOf(item);  
  473.             this .select(index,  false );  
  474.         }  
  475.     },  
  476.   
  477.     // private   
  478.     onViewClick : function(doFocus){  
  479.         var index = this .view.getSelectedIndexes()[ 0 ];  
  480.         var r = this .store.getAt(index);  
  481.         if (r){  
  482.             this .onSelect(r, index);  
  483.         }  
  484.         if (doFocus !==  false ){  
  485.             this .el.focus();  
  486.         }  
  487.     },  
  488.   
  489.     // private   
  490.     restrictHeight : function(){  
  491.         this .innerList.dom.style.height =  '' ;  
  492.         var inner = this .innerList.dom;  
  493.         var fw = this .list.getFrameWidth( 'tb' );  
  494.         var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);  
  495.         this .innerList.setHeight(h <  this .maxHeight ?  'auto'  :  this .maxHeight);  
  496.         this .list.beginUpdate();  
  497.         this .list.setHeight( this .innerList.getHeight()+fw+( this .resizable? this .handleHeight: 0 )+ this .assetHeight);  
  498.         this .list.alignTo( this .el,  this .listAlign);  
  499.         this .list.endUpdate();  
  500.     },  
  501.   
  502.     // private   
  503.     onEmptyResults : function(){  
  504.         this .collapse();  
  505.     },  
  506.   
  507.     /**  
  508.      * Returns true if the dropdown list is expanded, else false.  
  509.      */   
  510.     isExpanded : function(){  
  511.         return   this .list &&  this .list.isVisible();  
  512.     },  
  513.     selectByValue : function(v, scrollIntoView){  
  514.         if (v !== undefined && v !==  null ){  
  515.             var r = this .findRecord( this .valueField ||  this .displayField, v);  
  516.             if (r){  
  517.                 this .select( this .store.indexOf(r), scrollIntoView);  
  518.                 return   true ;  
  519.             }  
  520.         }  
  521.         return   false ;  
  522.     },  
  523.     select : function(index, scrollIntoView){  
  524.           
  525.         this .selectedIndex = index;  
  526.         this .view.select(index);  
  527.         if (scrollIntoView !==  false ){  
  528.             var el = this .view.getNode(index);  
  529.             if (el){  
  530.                 this .innerList.scrollChildIntoView(el,  false );  
  531.             }  
  532.         }  
  533.     },  
  534.   
  535.     // private   
  536.     selectNext : function(){  
  537.         var ct = this .store.getCount();  
  538.         if (ct >  0 ){  
  539.             if ( this .selectedIndex == - 1 ){  
  540.                 this .select( 0 );  
  541.             }else   if ( this .selectedIndex < ct- 1 ){  
  542.                 this .select( this .selectedIndex+ 1 );  
  543.             }  
  544.         }  
  545.     },  
  546.   
  547.     // private   
  548.     selectPrev : function(){  
  549.         var ct = this .store.getCount();  
  550.         if (ct >  0 ){  
  551.             if ( this .selectedIndex == - 1 ){  
  552.                 this .select( 0 );  
  553.             }else   if ( this .selectedIndex !=  0 ){  
  554.                 this .select( this .selectedIndex- 1 );  
  555.             }  
  556.         }  
  557.     },  
  558.   
  559.     // private   
  560.     onKeyUp : function(e){  
  561.         if ( this .editable !==  false  && !e.isSpecialKey()){  
  562.             this .lastKey = e.getKey();  
  563.             this .dqTask.delay( this .queryDelay);  
  564.         }  
  565.     },  
  566.   
  567.     // private   
  568.     validateBlur : function(){  
  569.         return  ! this .list || ! this .list.isVisible();     
  570.     },  
  571.   
  572.     // private   
  573.     initQuery : function(){  
  574.         this .doQuery( this .getRawValue());  
  575.     },  
  576.   
  577.     // private   
  578.     doForce : function(){  
  579.         if ( this .el.dom.value.length >  0 ){  
  580.             this .el.dom.value =  
  581.                 this .lastSelectionText === undefined ?  ''  :  this .lastSelectionText;  
  582.             this .applyEmptyText();  
  583.         }  
  584.     },  
  585.     doQuery : function(q, forceAll){  
  586.         if (q === undefined || q ===  null ){  
  587.             q = '' ;  
  588.         }  
  589.         var qe = {  
  590.             query: q,  
  591.             forceAll: forceAll,  
  592.             combo: this ,  
  593.             cancel:false   
  594.         };  
  595.         if ( this .fireEvent( 'beforequery' , qe)=== false  || qe.cancel){  
  596.             return   false ;  
  597.         }  
  598.         q = qe.query;  
  599.         forceAll = qe.forceAll;  
  600.         if (forceAll ===  true  || (q.length >=  this .minChars)){  
  601.             if ( this .lastQuery !== q){  
  602.                 this .lastQuery = q;  
  603.                 if ( this .mode ==  'local' ){  
  604.                     this .selectedIndex = - 1 ;  
  605.                     if (forceAll){  
  606.                         this .store.clearFilter();  
  607.                     }else {  
  608.                         this .store.filter( this .displayField, q);  
  609.                     }  
  610.                     this .onLoad();  
  611.                 }else {  
  612.                     this .store.baseParams[ this .queryParam] = q;  
  613.                     this .store.load({  
  614.                         params: this .getParams(q)  
  615.                     });  
  616.                     this .expand();  
  617.                 }  
  618.             }else {  
  619.                 this .selectedIndex = - 1 ;  
  620.                 this .onLoad();     
  621.             }  
  622.         }  
  623.     },  
  624.   
  625.     // private   
  626.     getParams : function(q){  
  627.         var p = {};  
  628.         //p[this.queryParam] = q;   
  629.         if ( this .pageSize){  
  630.             p.start = 0 ;  
  631.             p.limit = this .pageSize;  
  632.         }  
  633.         return  p;  
  634.     },  
  635.     /**  
  636.      * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.  
  637.      */   
  638.     collapse : function(){  
  639.         if (! this .isExpanded()){  
  640.             return ;  
  641.         }  
  642.         this .list.hide();  
  643.         Ext .getDoc().un('mousewheel' this .collapseIf,  this );  
  644.         Ext .getDoc().un('mousedown' this .collapseIf,  this );  
  645.         this .fireEvent( 'collapse' this );  
  646.     },  
  647.     // private   
  648.     collapseIf : function(e){  
  649.         if (!e.within( this .wrap) && !e.within( this .list)){  
  650.             this .collapse();  
  651.         }  
  652.     },  
  653.       
  654.     /**  
  655.      * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.  
  656.      */   
  657.     expand : function(){  
  658.         if ( this .isExpanded() || ! this .hasFocus){  
  659.             return ;  
  660.         }  
  661.         this .list.alignTo( this .wrap,  this .listAlign);  
  662.         var hvalueArray=this .hiddenField.value.split( this .valueSeparator);  
  663.         for (var i= 0 ;i< this .store.data.length;i++){  
  664.              var r = this .store.getAt(i);     
  665.              var newValue = r.data[this .displayField];  
  666.               var v=r.data[this .valueField];  
  667.               for (var j= 0 ;j<hvalueArray.length;j++){  
  668.                 if (hvalueArray[j]==v){  
  669.                     document.getElementById("checkBox_" +newValue).className= "checked" ;  
  670.                 }  
  671.               }  
  672.                
  673.         }   
  674.         this .list.show();  
  675.         Ext .getDoc().on('mousewheel' this .collapseIf,  this );  
  676.         Ext .getDoc().on('mousedown' this .collapseIf,  this );  
  677.         this .fireEvent( 'expand' this );  
  678.     },  
  679.   
  680.     // private   
  681.     // Implements the default empty TriggerField.onTriggerClick function   
  682.     onTriggerClick : function(){  
  683.         if ( this .disabled){  
  684.             return ;  
  685.         }  
  686.         if ( this .isExpanded()){  
  687.             this .collapse();  
  688.             this .el.focus();  
  689.         }else  {  
  690.             this .onFocus({});  
  691.             if ( this .triggerAction ==  'all' ) {  
  692.                 this .doQuery( this .allQuery,  true );  
  693.             } else  {  
  694.                 this .doQuery( this .getRawValue());  
  695.             }  
  696.             this .el.focus();  
  697.         }  
  698.     }  
  699. });  
  700. Ext .reg('multicombo' Ext .form.MultiComboBox);  
Ext
.form.MultiComboBox = Ext
.extend(Ext
.form.TriggerField, {
    defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},
    listClass: '',
    selectedClass: 'x-combo-selected',
    triggerClass : 'x-form-arrow-trigger',
    shadow:'sides',
    listAlign: 'tl-bl?',
    maxHeight: 300,
    triggerAction: 'query',
    minChars : 4,
    typeAhead: false,
    queryDelay: 500,
    pageSize: 0,
    selectOnFocus:false,
    queryParam: 'query',
    loadingText: 'Loading...',
    resizable: false,
    handleHeight : 8,
    editable: true,
    allQuery: '',
    mode: 'remote',
    minListWidth : 70,
    forceSelection:false,
    typeAheadDelay : 250,
    displaySeparator:';',
    valueSeparator:',',
    lazyInit : true,

    initComponent : function(){
        Ext
.form.ComboBox.superclass.initComponent.call(this);
        this.addEvents(
            'expand',
            'collapse',
            'beforeselect',
            'select',
            'beforequery'
        );
        if(this.transform){
            this.allowDomMove = false;
            var s = Ext
.getDom(this.transform);
            if(!this.hiddenName){
                this.hiddenName = s.name;
            }
            if(!this.store){
                this.mode = 'local';
                var d = [], opts = s.options;
                for(var i = 0, len = opts.length;i < len; i++){
                    var o = opts[i];
                    var value = (Ext
.isIE ? o.getAttributeNode('value').specified : o.hasAttribute('value')) ? o.value : o.text;
                    if(o.selected) {
                        this.value = value;
                    }
                    d.push([value, o.text]);
                }
                this.store = new Ext
.data.SimpleStore({
                    'id': 0,
                    fields: ['value', 'text'],
                    data : d
                });
                this.valueField = 'value';
                this.displayField = 'text';
            }
            s.name = Ext
.id(); // wipe out the name in case somewhere else they have a reference
            if(!this.lazyRender){
                this.target = true;
                this.el = Ext
.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);
                Ext
.removeNode(s); // remove it
                this.render(this.el.parentNode);
            }else{
                Ext
.removeNode(s); // remove it
            }

        }
        this.selectedIndex = -1;
        if(this.mode == 'local'){
            if(this.initialConfig.queryDelay === undefined){
                this.queryDelay = 10;
            }
            if(this.initialConfig.minChars === undefined){
                this.minChars = 0;
            }
        }
    },

    // private
    onRender : function(ct, position){
        Ext
.form.ComboBox.superclass.onRender.call(this, ct, position);
        var disValue="";
        if(this.hiddenName){
            this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName, id: (this.hiddenId||this.hiddenName)},
                    'before', true);
          var hvalue=this.hiddenValue !== undefined ? this.hiddenValue :
                this.value !== undefined ? this.value : '';
          var hvalueArray=hvalue.split(this.valueSeparator);
          
          for(var i=0;i<this.store.data.length;i++){
            	 var r = this.store.getAt(i);   
            	 var newValue = r.data[this.displayField];
            	  var v=r.data[this.valueField];
            	  for(var j=0;j<hvalueArray.length;j++){
            	  	if(hvalueArray[j]==v){
            	  		disValue+=newValue+this.displaySeparator;
            	  	}
            	  }
            	 
          }     
            this.hiddenField.value =this.hiddenValue !== undefined ? this.hiddenValue :
                this.value !== undefined ? this.value : '';
            this.el.dom.removeAttribute('name');
        }
        if(Ext
.isGecko){
            this.el.dom.setAttribute('autocomplete', 'off');
        }

        if(!this.lazyInit){
            this.initList();
        }else{
            this.on('focus', this.initList, this, {single: true});
        }

        if(!this.editable){
            this.editable = true;
            this.setEditable(false);
        }
        this.setValue(disValue);
    },

    initList : function(){
        if(!this.list){
            var cls = 'x-combo-list';

            this.list = new Ext
.Layer({
                shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
            });

            var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
            this.list.setWidth(lw);
            this.list.swallowEvent('mousewheel');
            this.assetHeight = 0;

            if(this.title){
                this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
                this.assetHeight += this.header.getHeight();
            }

            this.innerList = this.list.createChild({cls:cls+'-inner'});
            this.innerList.on('mouseover', this.onViewOver, this);
            this.innerList.on('mousemove', this.onViewMove, this);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'))

            if(this.pageSize){
                this.footer = this.list.createChild({cls:cls+'-ft'});
                this.pageTb = new Ext
.PagingToolbar({
                    store:this.store,
                    pageSize: this.pageSize,
                    renderTo:this.footer
                });
                this.assetHeight += this.footer.getHeight();
            }

            if(!this.tpl){
            	//alert(cls);
            	//x-combo-list-item
                this.tpl = '<tpl for="."><div class="'+cls+'-item"><span class="unchecked" id="checkBox_{' + this.displayField + '}"+ width="20">&nbsp;&nbsp;&nbsp;&nbsp;</span>{' + this.displayField + '}</div></tpl>';
            }
            this.view = new Ext
.DataView({
                applyTo: this.innerList,
                tpl: this.tpl,
                singleSelect: true,
                selectedClass: this.selectedClass,
                itemSelector: this.itemSelector || '.' + cls + '-item'
            });

            this.view.on('click', this.onViewClick, this);

            this.bindStore(this.store, true);

            if(this.resizable){
                this.resizer = new Ext
.Resizable(this.list,  {
                   pinned:true, handles:'se'
                });
                this.resizer.on('resize', function(r, w, h){
                    this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
                    this.listWidth = w;
                    this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
                    this.restrictHeight();
                }, this);
                this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
            }
        }
    },

    bindStore : function(store, initial){
        if(this.store && !initial){
            this.store.un('beforeload', this.onBeforeLoad, this);
            this.store.un('load', this.onLoad, this);
            this.store.un('loadexception', this.collapse, this);
            if(!store){
                this.store = null;
                if(this.view){
                    this.view.setStore(null);
                }
            }
        }
        if(store){
            this.store = Ext
.StoreMgr.lookup(store);

            this.store.on('beforeload', this.onBeforeLoad, this);
            this.store.on('load', this.onLoad, this);
            this.store.on('loadexception', this.collapse, this);

            if(this.view){
                this.view.setStore(store);
            }
        }
    },

    // private
    initEvents : function(){
        Ext
.form.ComboBox.superclass.initEvents.call(this);

        this.keyNav = new Ext
.KeyNav(this.el, {
            "up" : function(e){
                this.inKeyMode = true;
                this.selectPrev();
            },

            "down" : function(e){
                if(!this.isExpanded()){
                    this.onTriggerClick();
                }else{
                    this.inKeyMode = true;
                    this.selectNext();
                }
            },

            "enter" : function(e){
                this.onViewClick();
                //return true;
            },

            "esc" : function(e){
                this.collapse();
            },

            "tab" : function(e){
                this.onViewClick(false);
                return true;
            },

            scope : this,

            doRelay : function(foo, bar, hname){
                if(hname == 'down' || this.scope.isExpanded()){
                   return Ext
.KeyNav.prototype.doRelay.apply(this, arguments);
                }
                return true;
            },

            forceKeyDown : true
        });
        this.queryDelay = Math.max(this.queryDelay || 10,
                this.mode == 'local' ? 10 : 250);
        this.dqTask = new Ext
.util.DelayedTask(this.initQuery, this);
        if(this.typeAhead){
            this.taTask = new Ext
.util.DelayedTask(this.onTypeAhead, this);
        }
        if(this.editable !== false){
            this.el.on("keyup", this.onKeyUp, this);
        }
        if(this.forceSelection){
            this.on('blur', this.doForce, this);
        }
    },

    onDestroy : function(){
        if(this.view){
            this.view.el.removeAllListeners();
            this.view.el.remove();
            this.view.purgeListeners();
        }
        if(this.list){
            this.list.destroy();
        }
        this.bindStore(null);
        Ext
.form.ComboBox.superclass.onDestroy.call(this);
    },

    // private
    fireKey : function(e){
        if(e.isNavKeyPress() && !this.list.isVisible()){
            this.fireEvent("specialkey", this, e);
        }
    },

    // private
    onResize: function(w, h){
        Ext
.form.ComboBox.superclass.onResize.apply(this, arguments);
        if(this.list && this.listWidth === undefined){
            var lw = Math.max(w, this.minListWidth);
            this.list.setWidth(lw);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
        }
    },

    // private
    onDisable: function(){
        Ext
.form.ComboBox.superclass.onDisable.apply(this, arguments);
        if(this.hiddenField){
            this.hiddenField.disabled = this.disabled;
        }
    },
    setEditable : function(value){
        if(value == this.editable){
            return;
        }
        this.editable = value;
        if(!value){
            this.el.dom.setAttribute('readOnly', true);
            this.el.on('mousedown', this.onTriggerClick,  this);
            this.el.addClass('x-combo-noedit');
        }else{
            this.el.dom.setAttribute('readOnly', false);
            this.el.un('mousedown', this.onTriggerClick,  this);
            this.el.removeClass('x-combo-noedit');
        }
    },

    // private
    onBeforeLoad : function(){
        if(!this.hasFocus){
            return;
        }
        this.innerList.update(this.loadingText ?
               '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
        this.restrictHeight();
        this.selectedIndex = -1;
    },

    // private
    onLoad : function(){
        if(!this.hasFocus){
            return;
        }
        if(this.store.getCount() > 0){
            this.expand();
            this.restrictHeight();
            if(this.lastQuery == this.allQuery){
                if(this.editable){
                    this.el.dom.select();
                }
                if(!this.selectByValue(this.value, true)){
                    this.select(0, true);
                }
            }else{
                this.selectNext();
                if(this.typeAhead && this.lastKey != Ext
.EventObject.BACKSPACE && this.lastKey != Ext
.EventObject.DELETE){
                    this.taTask.delay(this.typeAheadDelay);
                }
            }
        }else{
            this.onEmptyResults();
        }
    },

    // private
    onTypeAhead : function(){
        if(this.store.getCount() > 0){
            var r = this.store.getAt(0);
            var newValue = r.data[this.displayField];
            var len = newValue.length;
            var selStart = this.getRawValue().length;
            if(selStart != len){
                this.setRawValue(newValue);
                this.selectText(selStart, newValue.length);
            }
        }
    },
    // private
    onSelect : function(record, index){
        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);
        }
    },
    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;
    },

    // private
    findRecord : function(prop, value){
        var record;
        if(this.store.getCount() > 0){
            this.store.each(function(r){
                if(r.data[prop] == value){
                    record = r;
                    return false;
                }
            });
        }
        return record;
    },

    // private
    onViewMove : function(e, t){
        this.inKeyMode = false;
    },

    // private
    onViewOver : function(e, t){
        if(this.inKeyMode){ // prevent key nav and mouse over conflicts
            return;
        }
        var item = this.view.findItemFromChild(t);
        if(item){
            var index = this.view.indexOf(item);
            this.select(index, false);
        }
    },

    // private
    onViewClick : function(doFocus){
        var index = this.view.getSelectedIndexes()[0];
        var r = this.store.getAt(index);
        if(r){
            this.onSelect(r, index);
        }
        if(doFocus !== false){
            this.el.focus();
        }
    },

    // private
    restrictHeight : function(){
        this.innerList.dom.style.height = '';
        var inner = this.innerList.dom;
        var fw = this.list.getFrameWidth('tb');
        var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
        this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
        this.list.beginUpdate();
        this.list.setHeight(this.innerList.getHeight()+fw+(this.resizable?this.handleHeight:0)+this.assetHeight);
        this.list.alignTo(this.el, this.listAlign);
        this.list.endUpdate();
    },

    // private
    onEmptyResults : function(){
        this.collapse();
    },

    /**
     * Returns true if the dropdown list is expanded, else false.
     */
    isExpanded : function(){
        return this.list && this.list.isVisible();
    },
    selectByValue : function(v, scrollIntoView){
        if(v !== undefined && v !== null){
            var r = this.findRecord(this.valueField || this.displayField, v);
            if(r){
                this.select(this.store.indexOf(r), scrollIntoView);
                return true;
            }
        }
        return false;
    },
    select : function(index, scrollIntoView){
    	
        this.selectedIndex = index;
        this.view.select(index);
        if(scrollIntoView !== false){
            var el = this.view.getNode(index);
            if(el){
                this.innerList.scrollChildIntoView(el, false);
            }
        }
    },

    // private
    selectNext : function(){
        var ct = this.store.getCount();
        if(ct > 0){
            if(this.selectedIndex == -1){
                this.select(0);
            }else if(this.selectedIndex < ct-1){
                this.select(this.selectedIndex+1);
            }
        }
    },

    // private
    selectPrev : function(){
        var ct = this.store.getCount();
        if(ct > 0){
            if(this.selectedIndex == -1){
                this.select(0);
            }else if(this.selectedIndex != 0){
                this.select(this.selectedIndex-1);
            }
        }
    },

    // private
    onKeyUp : function(e){
        if(this.editable !== false && !e.isSpecialKey()){
            this.lastKey = e.getKey();
            this.dqTask.delay(this.queryDelay);
        }
    },

    // private
    validateBlur : function(){
        return !this.list || !this.list.isVisible();   
    },

    // private
    initQuery : function(){
        this.doQuery(this.getRawValue());
    },

    // private
    doForce : function(){
        if(this.el.dom.value.length > 0){
            this.el.dom.value =
                this.lastSelectionText === undefined ? '' : this.lastSelectionText;
            this.applyEmptyText();
        }
    },
    doQuery : function(q, forceAll){
        if(q === undefined || q === null){
            q = '';
        }
        var qe = {
            query: q,
            forceAll: forceAll,
            combo: this,
            cancel:false
        };
        if(this.fireEvent('beforequery', qe)===false || qe.cancel){
            return false;
        }
        q = qe.query;
        forceAll = qe.forceAll;
        if(forceAll === true || (q.length >= this.minChars)){
            if(this.lastQuery !== q){
                this.lastQuery = q;
                if(this.mode == 'local'){
                    this.selectedIndex = -1;
                    if(forceAll){
                        this.store.clearFilter();
                    }else{
                        this.store.filter(this.displayField, q);
                    }
                    this.onLoad();
                }else{
                    this.store.baseParams[this.queryParam] = q;
                    this.store.load({
                        params: this.getParams(q)
                    });
                    this.expand();
                }
            }else{
                this.selectedIndex = -1;
                this.onLoad();   
            }
        }
    },

    // private
    getParams : function(q){
        var p = {};
        //p[this.queryParam] = q;
        if(this.pageSize){
            p.start = 0;
            p.limit = this.pageSize;
        }
        return p;
    },
    /**
     * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
     */
    collapse : function(){
        if(!this.isExpanded()){
            return;
        }
        this.list.hide();
        Ext
.getDoc().un('mousewheel', this.collapseIf, this);
        Ext
.getDoc().un('mousedown', this.collapseIf, this);
        this.fireEvent('collapse', this);
    },
    // private
    collapseIf : function(e){
        if(!e.within(this.wrap) && !e.within(this.list)){
            this.collapse();
        }
    },
    
    /**
     * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
     */
    expand : function(){
        if(this.isExpanded() || !this.hasFocus){
            return;
        }
        this.list.alignTo(this.wrap, this.listAlign);
        var hvalueArray=this.hiddenField.value.split(this.valueSeparator);
        for(var i=0;i<this.store.data.length;i++){
        	 var r = this.store.getAt(i);   
        	 var newValue = r.data[this.displayField];
        	  var v=r.data[this.valueField];
        	  for(var j=0;j<hvalueArray.length;j++){
        	  	if(hvalueArray[j]==v){
        	  		document.getElementById("checkBox_"+newValue).className="checked";
        	  	}
        	  }
        	 
        } 
        this.list.show();
        Ext
.getDoc().on('mousewheel', this.collapseIf, this);
        Ext
.getDoc().on('mousedown', this.collapseIf, this);
        this.fireEvent('expand', this);
    },

    // private
    // Implements the default empty TriggerField.onTriggerClick function
    onTriggerClick : function(){
        if(this.disabled){
            return;
        }
        if(this.isExpanded()){
            this.collapse();
            this.el.focus();
        }else {
            this.onFocus({});
            if(this.triggerAction == 'all') {
                this.doQuery(this.allQuery, true);
            } else {
                this.doQuery(this.getRawValue());
            }
            this.el.focus();
        }
    }
});
Ext
.reg('multicombo', Ext
.form.MultiComboBox);

  • 描述: 運行效果
  • 大小: 7.2 KB

<script type="text/javascript"><!-- google_ad_client = "pub-4348265167276910"; /* 468x60, 個人博客 */ google_ad_slot = "2046406163"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/expansion_embed.js"></script> <script src="http://googleads.g.doubleclick.net/pagead/test_domain.js"></script> <script>google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);</script>


前面已提到:
由於添加了多選CheckBox圖標,所以需要在ext -all.css文件最後添加兩行支持樣式:

Java代碼
  1. .checked{background-image:url(../images/ default /menu/checked.gif)}     
  2. .unchecked{background-image:url(../images/default /menu/unchecked.gif)}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章