7 * @class Roo.bootstrap.ComboBox
8 * @extends Roo.bootstrap.TriggerField
9 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
10 * @cfg {Boolean} append (true|false) default false
11 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
14 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
15 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
16 * @cfg {Boolean} animate default true
17 * @cfg {Boolean} emptyResultText only for touch device
19 * Create a new ComboBox.
20 * @param {Object} config Configuration options
22 Roo.bootstrap.ComboBox = function(config){
23 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
27 * Fires when the dropdown list is expanded
28 * @param {Roo.bootstrap.ComboBox} combo This combo box
33 * Fires when the dropdown list is collapsed
34 * @param {Roo.bootstrap.ComboBox} combo This combo box
39 * Fires before a list item is selected. Return false to cancel the selection.
40 * @param {Roo.bootstrap.ComboBox} combo This combo box
41 * @param {Roo.data.Record} record The data record returned from the underlying store
42 * @param {Number} index The index of the selected item in the dropdown list
44 'beforeselect' : true,
47 * Fires when a list item is selected
48 * @param {Roo.bootstrap.ComboBox} combo This combo box
49 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
50 * @param {Number} index The index of the selected item in the dropdown list
55 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
56 * The event object passed has these properties:
57 * @param {Roo.bootstrap.ComboBox} combo This combo box
58 * @param {String} query The query
59 * @param {Boolean} forceAll true to force "all" query
60 * @param {Boolean} cancel true to cancel the query
61 * @param {Object} e The query event object
66 * Fires when the 'add' icon is pressed (add a listener to enable add button)
67 * @param {Roo.bootstrap.ComboBox} combo This combo box
72 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
73 * @param {Roo.bootstrap.ComboBox} combo This combo box
74 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
79 * Fires when the remove value from the combobox array
80 * @param {Roo.bootstrap.ComboBox} combo This combo box
84 * @event specialfilter
85 * Fires when specialfilter
86 * @param {Roo.bootstrap.ComboBox} combo This combo box
88 'specialfilter' : true
95 this.selectedIndex = -1;
96 if(this.mode == 'local'){
97 if(config.queryDelay === undefined){
100 if(config.minChars === undefined){
106 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
109 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
110 * rendering into an Roo.Editor, defaults to false)
113 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
114 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
117 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
120 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
121 * the dropdown list (defaults to undefined, with no header element)
125 * @cfg {String/Roo.Template} tpl The template to use to render the output
129 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
131 listWidth: undefined,
133 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
134 * mode = 'remote' or 'text' if mode = 'local')
136 displayField: undefined,
139 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
140 * mode = 'remote' or 'value' if mode = 'local').
141 * Note: use of a valueField requires the user make a selection
142 * in order for a value to be mapped.
144 valueField: undefined,
148 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
149 * field's data value (defaults to the underlying DOM element's name)
151 hiddenName: undefined,
153 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
157 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
159 selectedClass: 'active',
162 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
166 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
167 * anchor positions (defaults to 'tl-bl')
171 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
175 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
176 * query specified by the allQuery config option (defaults to 'query')
178 triggerAction: 'query',
180 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
181 * (defaults to 4, does not apply if editable = false)
185 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
186 * delay (typeAheadDelay) if it matches a known value (defaults to false)
190 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
191 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
195 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
196 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
200 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
201 * when editable = true (defaults to false)
205 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
209 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
210 * when mode = 'remote' (defaults to 'Loading...')
212 loadingText: 'Loading...',
214 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
218 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
222 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
223 * traditional select (defaults to true)
227 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
231 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
235 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
236 * listWidth has a higher value)
240 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
241 * allow the user to set arbitrary text into the field (defaults to false)
243 forceSelection:false,
245 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
246 * if typeAhead = true (defaults to 250)
248 typeAheadDelay : 250,
250 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
251 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
253 valueNotFoundText : undefined,
255 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
260 * @cfg {Boolean} disableClear Disable showing of clear button.
262 disableClear : false,
264 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
269 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
274 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
276 invalidClass : "has-warning",
279 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
281 validClass : "has-success",
284 * @cfg {Boolean} specialFilter (true|false) special filter default false
286 specialFilter : false,
289 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
291 mobileTouchView : true,
303 btnPosition : 'right',
305 showToggleBtn : true,
307 emptyResultText: 'Empty',
308 // element that contains real text value.. (when hidden is used..)
310 getAutoCreate : function()
318 if(Roo.isTouch && this.mobileTouchView){
319 cfg = this.getAutoCreateTouchView();
327 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
332 * ComboBox with tickable selections
335 var align = this.labelAlign || this.parentLabelAlign();
338 cls : 'form-group roo-combobox-tickable' //input-group
343 cls : 'tickable-buttons',
348 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
355 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
362 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
371 cls: 'select2-search-field-input'
377 Roo.each(buttons.cn, function(c){
379 c.cls += ' btn-' + _this.size;
382 if (_this.disabled) {
393 cls: 'form-hidden-field'
397 cls: 'select2-choices',
401 cls: 'select2-search-field',
413 cls: 'select2-container input-group select2-container-multi',
418 // cls: 'typeahead typeahead-long dropdown-menu',
419 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
424 if(this.hasFeedback && !this.allowBlank){
428 cls: 'glyphicon form-control-feedback'
431 combobox.cn.push(feedback);
434 if (align ==='left' && this.fieldLabel.length) {
436 Roo.log("left and has label");
442 cls : 'control-label col-sm-' + this.labelWidth,
443 html : this.fieldLabel
447 cls : "col-sm-" + (12 - this.labelWidth),
454 } else if ( this.fieldLabel.length) {
460 //cls : 'input-group-addon',
461 html : this.fieldLabel
471 Roo.log(" no label && no align");
478 ['xs','sm','md','lg'].map(function(size){
479 if (settings[size]) {
480 cfg.cls += ' col-' + size + '-' + settings[size];
489 initEvents: function()
493 throw "can not find store for combo";
496 this.store = Roo.factory(this.store, Roo.data);
502 if(Roo.isTouch && this.mobileTouchView){
503 this.initTouchView();
508 this.initTickableEvents();
512 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
516 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
518 this.hiddenField.dom.value =
519 this.hiddenValue !== undefined ? this.hiddenValue :
520 this.value !== undefined ? this.value : '';
522 // prevent input submission
523 this.el.dom.removeAttribute('name');
524 this.hiddenField.dom.setAttribute('name', this.hiddenName);
529 // this.el.dom.setAttribute('autocomplete', 'off');
532 var cls = 'x-combo-list';
534 //this.list = new Roo.Layer({
535 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
541 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
542 _this.list.setWidth(lw);
545 this.list.on('mouseover', this.onViewOver, this);
546 this.list.on('mousemove', this.onViewMove, this);
548 this.list.on('scroll', this.onViewScroll, this);
551 this.list.swallowEvent('mousewheel');
552 this.assetHeight = 0;
555 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
556 this.assetHeight += this.header.getHeight();
559 this.innerList = this.list.createChild({cls:cls+'-inner'});
560 this.innerList.on('mouseover', this.onViewOver, this);
561 this.innerList.on('mousemove', this.onViewMove, this);
562 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
564 if(this.allowBlank && !this.pageSize && !this.disableClear){
565 this.footer = this.list.createChild({cls:cls+'-ft'});
566 this.pageTb = new Roo.Toolbar(this.footer);
570 this.footer = this.list.createChild({cls:cls+'-ft'});
571 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
572 {pageSize: this.pageSize});
576 if (this.pageTb && this.allowBlank && !this.disableClear) {
578 this.pageTb.add(new Roo.Toolbar.Fill(), {
579 cls: 'x-btn-icon x-btn-clear',
585 _this.onSelect(false, -1);
590 this.assetHeight += this.footer.getHeight();
595 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
598 this.view = new Roo.View(this.list, this.tpl, {
599 singleSelect:true, store: this.store, selectedClass: this.selectedClass
601 //this.view.wrapEl.setDisplayed(false);
602 this.view.on('click', this.onViewClick, this);
606 this.store.on('beforeload', this.onBeforeLoad, this);
607 this.store.on('load', this.onLoad, this);
608 this.store.on('loadexception', this.onLoadException, this);
611 this.resizer = new Roo.Resizable(this.list, {
612 pinned:true, handles:'se'
614 this.resizer.on('resize', function(r, w, h){
615 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
617 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
618 this.restrictHeight();
620 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
624 this.editable = true;
625 this.setEditable(false);
630 if (typeof(this.events.add.listeners) != 'undefined') {
632 this.addicon = this.wrap.createChild(
633 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
635 this.addicon.on('click', function(e) {
636 this.fireEvent('add', this);
639 if (typeof(this.events.edit.listeners) != 'undefined') {
641 this.editicon = this.wrap.createChild(
642 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
644 this.editicon.setStyle('margin-left', '40px');
646 this.editicon.on('click', function(e) {
648 // we fire even if inothing is selected..
649 this.fireEvent('edit', this, this.lastData );
655 this.keyNav = new Roo.KeyNav(this.inputEl(), {
657 this.inKeyMode = true;
661 "down" : function(e){
662 if(!this.isExpanded()){
663 this.onTriggerClick();
665 this.inKeyMode = true;
670 "enter" : function(e){
671 // this.onViewClick();
675 if(this.fireEvent("specialkey", this, e)){
676 this.onViewClick(false);
689 if(this.fireEvent("specialkey", this, e)){
690 this.onViewClick(false);
698 doRelay : function(foo, bar, hname){
699 if(hname == 'down' || this.scope.isExpanded()){
700 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
709 this.queryDelay = Math.max(this.queryDelay || 10,
710 this.mode == 'local' ? 10 : 250);
713 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
716 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
718 if(this.editable !== false){
719 this.inputEl().on("keyup", this.onKeyUp, this);
721 if(this.forceSelection){
722 this.inputEl().on('blur', this.doForce, this);
726 this.choices = this.el.select('ul.select2-choices', true).first();
727 this.searchField = this.el.select('ul li.select2-search-field', true).first();
731 initTickableEvents: function()
737 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
739 this.hiddenField.dom.value =
740 this.hiddenValue !== undefined ? this.hiddenValue :
741 this.value !== undefined ? this.value : '';
743 // prevent input submission
744 this.el.dom.removeAttribute('name');
745 this.hiddenField.dom.setAttribute('name', this.hiddenName);
750 // this.list = this.el.select('ul.dropdown-menu',true).first();
752 this.choices = this.el.select('ul.select2-choices', true).first();
753 this.searchField = this.el.select('ul li.select2-search-field', true).first();
754 if(this.triggerList){
755 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
758 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
759 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
761 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
762 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
764 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
765 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
767 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
768 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
769 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
772 this.cancelBtn.hide();
777 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
778 _this.list.setWidth(lw);
781 this.list.on('mouseover', this.onViewOver, this);
782 this.list.on('mousemove', this.onViewMove, this);
784 this.list.on('scroll', this.onViewScroll, this);
787 this.tpl = '<li class="select2-result"><div class="checkbox"><input id="{roo-id}" type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></li>';
790 this.view = new Roo.View(this.list, this.tpl, {
791 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
794 //this.view.wrapEl.setDisplayed(false);
795 this.view.on('click', this.onViewClick, this);
799 this.store.on('beforeload', this.onBeforeLoad, this);
800 this.store.on('load', this.onLoad, this);
801 this.store.on('loadexception', this.onLoadException, this);
804 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
806 this.inKeyMode = true;
810 "down" : function(e){
811 this.inKeyMode = true;
815 "enter" : function(e){
816 if(this.fireEvent("specialkey", this, e)){
817 this.onViewClick(false);
824 this.onTickableFooterButtonClick(e, false, false);
828 this.fireEvent("specialkey", this, e);
830 this.onTickableFooterButtonClick(e, false, false);
837 doRelay : function(e, fn, key){
838 if(this.scope.isExpanded()){
839 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
848 this.queryDelay = Math.max(this.queryDelay || 10,
849 this.mode == 'local' ? 10 : 250);
852 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
855 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
858 if(this.editable !== false){
859 this.tickableInputEl().on("keyup", this.onKeyUp, this);
864 onDestroy : function(){
866 this.view.setStore(null);
867 this.view.el.removeAllListeners();
868 this.view.el.remove();
869 this.view.purgeListeners();
872 this.list.dom.innerHTML = '';
876 this.store.un('beforeload', this.onBeforeLoad, this);
877 this.store.un('load', this.onLoad, this);
878 this.store.un('loadexception', this.onLoadException, this);
880 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
884 fireKey : function(e){
885 if(e.isNavKeyPress() && !this.list.isVisible()){
886 this.fireEvent("specialkey", this, e);
891 onResize: function(w, h){
892 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
894 // if(typeof w != 'number'){
895 // // we do not handle it!?!?
898 // var tw = this.trigger.getWidth();
899 // // tw += this.addicon ? this.addicon.getWidth() : 0;
900 // // tw += this.editicon ? this.editicon.getWidth() : 0;
902 // this.inputEl().setWidth( this.adjustWidth('input', x));
904 // //this.trigger.setStyle('left', x+'px');
906 // if(this.list && this.listWidth === undefined){
907 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
908 // this.list.setWidth(lw);
909 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
917 * Allow or prevent the user from directly editing the field text. If false is passed,
918 * the user will only be able to select from the items defined in the dropdown list. This method
919 * is the runtime equivalent of setting the 'editable' config option at config time.
920 * @param {Boolean} value True to allow the user to directly edit the field text
922 setEditable : function(value){
923 if(value == this.editable){
926 this.editable = value;
928 this.inputEl().dom.setAttribute('readOnly', true);
929 this.inputEl().on('mousedown', this.onTriggerClick, this);
930 this.inputEl().addClass('x-combo-noedit');
932 this.inputEl().dom.setAttribute('readOnly', false);
933 this.inputEl().un('mousedown', this.onTriggerClick, this);
934 this.inputEl().removeClass('x-combo-noedit');
940 onBeforeLoad : function(combo,opts){
945 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
947 this.restrictHeight();
948 this.selectedIndex = -1;
954 this.hasQuery = false;
960 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
964 if(this.store.getCount() > 0){
966 this.restrictHeight();
967 if(this.lastQuery == this.allQuery){
968 if(this.editable && !this.tickable){
969 this.inputEl().dom.select();
973 !this.selectByValue(this.value, true) &&
976 !this.store.lastOptions ||
977 typeof(this.store.lastOptions.add) == 'undefined' ||
978 this.store.lastOptions.add != true
981 this.select(0, true);
987 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
988 this.taTask.delay(this.typeAheadDelay);
992 this.onEmptyResults();
998 onLoadException : function()
1000 this.hasQuery = false;
1002 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
1003 this.loading.hide();
1006 if(this.tickable && this.editable){
1012 Roo.log(this.store.reader.jsonData);
1013 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
1015 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
1021 onTypeAhead : function(){
1022 if(this.store.getCount() > 0){
1023 var r = this.store.getAt(0);
1024 var newValue = r.data[this.displayField];
1025 var len = newValue.length;
1026 var selStart = this.getRawValue().length;
1028 if(selStart != len){
1029 this.setRawValue(newValue);
1030 this.selectText(selStart, newValue.length);
1036 onSelect : function(record, index){
1038 if(this.fireEvent('beforeselect', this, record, index) !== false){
1040 this.setFromData(index > -1 ? record.data : false);
1043 this.fireEvent('select', this, record, index);
1048 * Returns the currently selected field value or empty string if no value is set.
1049 * @return {String} value The selected value
1051 getValue : function(){
1054 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
1057 if(this.valueField){
1058 return typeof this.value != 'undefined' ? this.value : '';
1060 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
1065 * Clears any text/value currently set in the field
1067 clearValue : function(){
1068 if(this.hiddenField){
1069 this.hiddenField.dom.value = '';
1072 this.setRawValue('');
1073 this.lastSelectionText = '';
1074 this.lastData = false;
1076 var close = this.closeTriggerEl();
1085 * Sets the specified value into the field. If the value finds a match, the corresponding record text
1086 * will be displayed in the field. If the value does not match the data value of an existing item,
1087 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
1088 * Otherwise the field will be blank (although the value will still be set).
1089 * @param {String} value The value to match
1091 setValue : function(v){
1098 if(this.valueField){
1099 var r = this.findRecord(this.valueField, v);
1101 text = r.data[this.displayField];
1102 }else if(this.valueNotFoundText !== undefined){
1103 text = this.valueNotFoundText;
1106 this.lastSelectionText = text;
1107 if(this.hiddenField){
1108 this.hiddenField.dom.value = v;
1110 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
1113 var close = this.closeTriggerEl();
1116 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
1120 * @property {Object} the last set data for the element
1125 * Sets the value of the field based on a object which is related to the record format for the store.
1126 * @param {Object} value the value to set as. or false on reset?
1128 setFromData : function(o){
1135 var dv = ''; // display value
1136 var vv = ''; // value value..
1138 if (this.displayField) {
1139 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
1141 // this is an error condition!!!
1142 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
1145 if(this.valueField){
1146 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
1149 var close = this.closeTriggerEl();
1152 (vv.length || vv * 1 > 0) ? close.show() : close.hide();
1155 if(this.hiddenField){
1156 this.hiddenField.dom.value = vv;
1158 this.lastSelectionText = dv;
1159 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
1163 // no hidden field.. - we store the value in 'value', but still display
1164 // display field!!!!
1165 this.lastSelectionText = dv;
1166 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
1174 // overridden so that last data is reset..
1181 this.setValue(this.originalValue);
1182 this.clearInvalid();
1183 this.lastData = false;
1185 this.view.clearSelections();
1189 findRecord : function(prop, value){
1191 if(this.store.getCount() > 0){
1192 this.store.each(function(r){
1193 if(r.data[prop] == value){
1205 // returns hidden if it's set..
1206 if (!this.rendered) {return ''};
1207 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
1211 onViewMove : function(e, t){
1212 this.inKeyMode = false;
1216 onViewOver : function(e, t){
1217 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
1220 var item = this.view.findItemFromChild(t);
1223 var index = this.view.indexOf(item);
1224 this.select(index, false);
1229 onViewClick : function(view, doFocus, el, e)
1231 var index = this.view.getSelectedIndexes()[0];
1233 var r = this.store.getAt(index);
1237 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
1244 Roo.each(this.tickItems, function(v,k){
1246 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
1247 _this.tickItems.splice(k, 1);
1249 if(typeof(e) == 'undefined' && view == false){
1250 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
1262 this.tickItems.push(r.data);
1264 if(typeof(e) == 'undefined' && view == false){
1265 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
1272 this.onSelect(r, index);
1274 if(doFocus !== false && !this.blockFocus){
1275 this.inputEl().focus();
1280 restrictHeight : function(){
1281 //this.innerList.dom.style.height = '';
1282 //var inner = this.innerList.dom;
1283 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
1284 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
1285 //this.list.beginUpdate();
1286 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
1287 this.list.alignTo(this.inputEl(), this.listAlign);
1288 this.list.alignTo(this.inputEl(), this.listAlign);
1289 //this.list.endUpdate();
1293 onEmptyResults : function(){
1295 if(this.tickable && this.editable){
1296 this.restrictHeight();
1304 * Returns true if the dropdown list is expanded, else false.
1306 isExpanded : function(){
1307 return this.list.isVisible();
1311 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
1312 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1313 * @param {String} value The data value of the item to select
1314 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1315 * selected item if it is not currently in view (defaults to true)
1316 * @return {Boolean} True if the value matched an item in the list, else false
1318 selectByValue : function(v, scrollIntoView){
1319 if(v !== undefined && v !== null){
1320 var r = this.findRecord(this.valueField || this.displayField, v);
1322 this.select(this.store.indexOf(r), scrollIntoView);
1330 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
1331 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1332 * @param {Number} index The zero-based index of the list item to select
1333 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1334 * selected item if it is not currently in view (defaults to true)
1336 select : function(index, scrollIntoView){
1337 this.selectedIndex = index;
1338 this.view.select(index);
1339 if(scrollIntoView !== false){
1340 var el = this.view.getNode(index);
1342 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
1345 this.list.scrollChildIntoView(el, false);
1351 selectNext : function(){
1352 var ct = this.store.getCount();
1354 if(this.selectedIndex == -1){
1356 }else if(this.selectedIndex < ct-1){
1357 this.select(this.selectedIndex+1);
1363 selectPrev : function(){
1364 var ct = this.store.getCount();
1366 if(this.selectedIndex == -1){
1368 }else if(this.selectedIndex != 0){
1369 this.select(this.selectedIndex-1);
1375 onKeyUp : function(e){
1376 if(this.editable !== false && !e.isSpecialKey()){
1377 this.lastKey = e.getKey();
1378 this.dqTask.delay(this.queryDelay);
1383 validateBlur : function(){
1384 return !this.list || !this.list.isVisible();
1388 initQuery : function(){
1390 var v = this.getRawValue();
1392 if(this.tickable && this.editable){
1393 v = this.tickableInputEl().getValue();
1400 doForce : function(){
1401 if(this.inputEl().dom.value.length > 0){
1402 this.inputEl().dom.value =
1403 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
1409 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
1410 * query allowing the query action to be canceled if needed.
1411 * @param {String} query The SQL query to execute
1412 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
1413 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
1414 * saved in the current store (defaults to false)
1416 doQuery : function(q, forceAll){
1418 if(q === undefined || q === null){
1427 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
1432 forceAll = qe.forceAll;
1433 if(forceAll === true || (q.length >= this.minChars)){
1435 this.hasQuery = true;
1437 if(this.lastQuery != q || this.alwaysQuery){
1439 if(this.mode == 'local'){
1440 this.selectedIndex = -1;
1442 this.store.clearFilter();
1445 if(this.specialFilter){
1446 this.fireEvent('specialfilter', this);
1451 this.store.filter(this.displayField, q);
1454 this.store.fireEvent("datachanged", this.store);
1461 this.store.baseParams[this.queryParam] = q;
1463 var options = {params : this.getParams(q)};
1467 options.params.start = this.page * this.pageSize;
1470 this.store.load(options);
1473 * this code will make the page width larger, at the beginning, the list not align correctly,
1474 * we should expand the list on onLoad
1480 this.selectedIndex = -1;
1485 this.loadNext = false;
1489 getParams : function(q){
1491 //p[this.queryParam] = q;
1495 p.limit = this.pageSize;
1501 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
1503 collapse : function(){
1504 if(!this.isExpanded()){
1511 this.hasFocus = false;
1513 this.cancelBtn.hide();
1514 this.trigger.show();
1517 this.tickableInputEl().dom.value = '';
1518 this.tickableInputEl().blur();
1523 Roo.get(document).un('mousedown', this.collapseIf, this);
1524 Roo.get(document).un('mousewheel', this.collapseIf, this);
1525 if (!this.editable) {
1526 Roo.get(document).un('keydown', this.listKeyPress, this);
1528 this.fireEvent('collapse', this);
1532 collapseIf : function(e){
1533 var in_combo = e.within(this.el);
1534 var in_list = e.within(this.list);
1535 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
1537 if (in_combo || in_list || is_list) {
1538 //e.stopPropagation();
1543 this.onTickableFooterButtonClick(e, false, false);
1551 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
1553 expand : function(){
1555 if(this.isExpanded() || !this.hasFocus){
1559 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
1560 this.list.setWidth(lw);
1567 this.restrictHeight();
1571 this.tickItems = Roo.apply([], this.item);
1574 this.cancelBtn.show();
1575 this.trigger.hide();
1578 this.tickableInputEl().focus();
1583 Roo.get(document).on('mousedown', this.collapseIf, this);
1584 Roo.get(document).on('mousewheel', this.collapseIf, this);
1585 if (!this.editable) {
1586 Roo.get(document).on('keydown', this.listKeyPress, this);
1589 this.fireEvent('expand', this);
1593 // Implements the default empty TriggerField.onTriggerClick function
1594 onTriggerClick : function(e)
1596 Roo.log('trigger click');
1598 if(this.disabled || !this.triggerList){
1603 this.loadNext = false;
1605 if(this.isExpanded()){
1607 if (!this.blockFocus) {
1608 this.inputEl().focus();
1612 this.hasFocus = true;
1613 if(this.triggerAction == 'all') {
1614 this.doQuery(this.allQuery, true);
1616 this.doQuery(this.getRawValue());
1618 if (!this.blockFocus) {
1619 this.inputEl().focus();
1624 onTickableTriggerClick : function(e)
1631 this.loadNext = false;
1632 this.hasFocus = true;
1634 if(this.triggerAction == 'all') {
1635 this.doQuery(this.allQuery, true);
1637 this.doQuery(this.getRawValue());
1641 onSearchFieldClick : function(e)
1643 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
1644 this.onTickableFooterButtonClick(e, false, false);
1648 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
1653 this.loadNext = false;
1654 this.hasFocus = true;
1656 if(this.triggerAction == 'all') {
1657 this.doQuery(this.allQuery, true);
1659 this.doQuery(this.getRawValue());
1663 listKeyPress : function(e)
1665 //Roo.log('listkeypress');
1666 // scroll to first matching element based on key pres..
1667 if (e.isSpecialKey()) {
1670 var k = String.fromCharCode(e.getKey()).toUpperCase();
1673 var csel = this.view.getSelectedNodes();
1674 var cselitem = false;
1676 var ix = this.view.indexOf(csel[0]);
1677 cselitem = this.store.getAt(ix);
1678 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
1684 this.store.each(function(v) {
1686 // start at existing selection.
1687 if (cselitem.id == v.id) {
1693 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
1694 match = this.store.indexOf(v);
1700 if (match === false) {
1701 return true; // no more action?
1704 this.view.select(match);
1705 var sn = Roo.get(this.view.getSelectedNodes()[0])
1706 sn.scrollIntoView(sn.dom.parentNode, false);
1709 onViewScroll : function(e, t){
1711 if(this.view.el.getScroll().top == 0 ||this.view.el.getScroll().top < this.view.el.dom.scrollHeight - this.view.el.dom.clientHeight || !this.hasFocus || !this.append || this.hasQuery){
1715 this.hasQuery = true;
1717 this.loading = this.list.select('.loading', true).first();
1719 if(this.loading === null){
1720 this.list.createChild({
1722 cls: 'loading select2-more-results select2-active',
1723 html: 'Loading more results...'
1726 this.loading = this.list.select('.loading', true).first();
1728 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
1730 this.loading.hide();
1733 this.loading.show();
1738 this.loadNext = true;
1740 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
1745 addItem : function(o)
1747 var dv = ''; // display value
1749 if (this.displayField) {
1750 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
1752 // this is an error condition!!!
1753 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
1760 var choice = this.choices.createChild({
1762 cls: 'select2-search-choice',
1771 cls: 'select2-search-choice-close',
1776 }, this.searchField);
1778 var close = choice.select('a.select2-search-choice-close', true).first()
1780 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
1788 this.inputEl().dom.value = '';
1793 onRemoveItem : function(e, _self, o)
1797 this.lastItem = Roo.apply([], this.item);
1799 var index = this.item.indexOf(o.data) * 1;
1802 Roo.log('not this item?!');
1806 this.item.splice(index, 1);
1811 this.fireEvent('remove', this, e);
1817 syncValue : function()
1819 if(!this.item.length){
1826 Roo.each(this.item, function(i){
1827 if(_this.valueField){
1828 value.push(i[_this.valueField]);
1835 this.value = value.join(',');
1837 if(this.hiddenField){
1838 this.hiddenField.dom.value = this.value;
1841 this.store.fireEvent("datachanged", this.store);
1844 clearItem : function()
1852 Roo.each(this.choices.select('>li.select2-search-choice', true).elements, function(c){
1861 inputEl: function ()
1863 if(Roo.isTouch && this.mobileTouchView){
1864 return this.el.select('input.form-control',true).first();
1868 return this.searchField;
1871 return this.el.select('input.form-control',true).first();
1875 onTickableFooterButtonClick : function(e, btn, el)
1879 this.lastItem = Roo.apply([], this.item);
1881 if(btn && btn.name == 'cancel'){
1882 this.tickItems = Roo.apply([], this.item);
1891 Roo.each(this.tickItems, function(o){
1899 validate : function()
1901 var v = this.getRawValue();
1904 v = this.getValue();
1907 if(this.disabled || this.allowBlank || v.length){
1916 tickableInputEl : function()
1918 if(!this.tickable || !this.editable){
1919 return this.inputEl();
1922 return this.inputEl().select('.select2-search-field-input', true).first();
1926 getAutoCreateTouchView : function()
1931 cls: 'form-group' //input-group
1937 type : this.inputType,
1938 cls : 'form-control x-combo-noedit',
1939 autocomplete: 'new-password',
1940 placeholder : this.placeholder || '',
1945 input.name = this.name;
1949 input.cls += ' input-' + this.size;
1952 if (this.disabled) {
1953 input.disabled = true;
1964 inputblock.cls += ' input-group';
1966 inputblock.cn.unshift({
1968 cls : 'input-group-addon',
1973 if(this.removable && !this.multiple){
1974 inputblock.cls += ' roo-removable';
1976 inputblock.cn.push({
1979 cls : 'roo-combo-removable-btn close'
1983 if(this.hasFeedback && !this.allowBlank){
1985 inputblock.cls += ' has-feedback';
1987 inputblock.cn.push({
1989 cls: 'glyphicon form-control-feedback'
1996 inputblock.cls += (this.before) ? '' : ' input-group';
1998 inputblock.cn.push({
2000 cls : 'input-group-addon',
2011 cls: 'form-hidden-field'
2025 cls: 'form-hidden-field'
2029 cls: 'select2-choices',
2033 cls: 'select2-search-field',
2046 cls: 'select2-container input-group',
2053 combobox.cls += ' select2-container-multi';
2056 var align = this.labelAlign || this.parentLabelAlign();
2060 if(this.fieldLabel.length){
2062 var lw = align === 'left' ? ('col-sm' + this.labelWidth) : '';
2063 var cw = align === 'left' ? ('col-sm' + (12 - this.labelWidth)) : '';
2068 cls : 'control-label ' + lw,
2069 html : this.fieldLabel
2081 var settings = this;
2083 ['xs','sm','md','lg'].map(function(size){
2084 if (settings[size]) {
2085 cfg.cls += ' col-' + size + '-' + settings[size];
2092 initTouchView : function()
2094 this.renderTouchView();
2096 this.touchViewEl.on('scroll', function(){
2097 this.el.dom.scrollTop = 0;
2100 this.inputEl().on("click", this.showTouchView, this);
2101 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
2102 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
2104 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
2106 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
2107 this.store.on('load', this.onTouchViewLoad, this);
2108 this.store.on('loadexception', this.onTouchViewLoadException, this);
2110 if(this.hiddenName){
2112 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
2114 this.hiddenField.dom.value =
2115 this.hiddenValue !== undefined ? this.hiddenValue :
2116 this.value !== undefined ? this.value : '';
2118 this.el.dom.removeAttribute('name');
2119 this.hiddenField.dom.setAttribute('name', this.hiddenName);
2123 this.choices = this.el.select('ul.select2-choices', true).first();
2124 this.searchField = this.el.select('ul li.select2-search-field', true).first();
2127 if(this.removable && !this.multiple){
2128 var close = this.closeTriggerEl();
2130 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
2131 close.on('click', this.removeBtnClick, this, close);
2140 renderTouchView : function()
2142 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
2143 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2145 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
2146 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2148 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
2149 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2150 this.touchViewBodyEl.setStyle('overflow', 'auto');
2152 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
2153 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2155 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
2156 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2160 showTouchView : function()
2162 this.touchViewHeaderEl.hide();
2164 if(this.fieldLabel.length){
2165 this.touchViewHeaderEl.dom.innerHTML = this.fieldLabel;
2166 this.touchViewHeaderEl.show();
2169 this.touchViewEl.show();
2171 this.touchViewEl.select('.modal-dialog', true).first().setStyle('margin', '0px');
2172 this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2174 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
2176 if(this.fieldLabel.length){
2177 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
2180 this.touchViewBodyEl.setHeight(bodyHeight);
2184 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
2186 this.touchViewEl.addClass('in');
2189 this.doTouchViewQuery();
2193 hideTouchView : function()
2195 this.touchViewEl.removeClass('in');
2199 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
2201 this.touchViewEl.setStyle('display', 'none');
2206 setTouchViewValue : function()
2213 Roo.each(this.tickItems, function(o){
2218 this.hideTouchView();
2221 doTouchViewQuery : function()
2230 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
2234 if(!this.alwaysQuery || this.mode == 'local'){
2235 this.onTouchViewLoad();
2242 onTouchViewBeforeLoad : function(combo,opts)
2248 onTouchViewLoad : function()
2250 if(this.store.getCount() < 1){
2251 this.onTouchViewEmptyResults();
2255 this.clearTouchView();
2257 var rawValue = this.getRawValue();
2259 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
2261 this.tickItems = [];
2263 this.store.data.each(function(d, rowIndex){
2264 var row = this.touchViewListGroup.createChild(template);
2266 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
2267 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = d.data[this.displayField];
2270 if(!this.multiple && this.valueField && typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue()){
2271 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2274 if(this.multiple && this.valueField && typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1){
2275 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2276 this.tickItems.push(d.data);
2279 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
2283 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
2285 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
2287 if(this.fieldLabel.length){
2288 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
2291 var listHeight = this.touchViewListGroup.getHeight();
2293 if(firstChecked && listHeight > bodyHeight){
2294 (function() { firstChecked.findParent('li').scrollIntoView(this.touchViewListGroup.dom); }).defer(500);
2299 onTouchViewLoadException : function()
2301 this.hideTouchView();
2304 onTouchViewEmptyResults : function()
2306 this.clearTouchView();
2308 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
2310 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
2314 clearTouchView : function()
2316 this.touchViewListGroup.dom.innerHTML = '';
2319 onTouchViewClick : function(e, el, o)
2324 var rowIndex = o.rowIndex;
2326 var r = this.store.getAt(rowIndex);
2329 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
2330 c.dom.removeAttribute('checked');
2333 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2335 this.setFromData(r.data);
2337 var close = this.closeTriggerEl();
2343 this.hideTouchView();
2345 this.fireEvent('select', this, r, rowIndex);
2350 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
2351 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
2352 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
2356 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2357 this.addItem(r.data);
2358 this.tickItems.push(r.data);
2364 * @cfg {Boolean} grow
2368 * @cfg {Number} growMin
2372 * @cfg {Number} growMax
2381 Roo.apply(Roo.bootstrap.ComboBox, {
2385 cls: 'modal-header',
2407 cls: 'list-group-item',
2411 cls: 'roo-combobox-list-group-item-value'
2415 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
2429 listItemCheckbox : {
2431 cls: 'list-group-item',
2435 cls: 'roo-combobox-list-group-item-value'
2439 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
2455 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
2460 cls: 'modal-footer',
2468 cls: 'col-xs-6 text-left',
2471 cls: 'btn btn-danger roo-touch-view-cancel',
2477 cls: 'col-xs-6 text-right',
2480 cls: 'btn btn-success roo-touch-view-ok',
2491 Roo.apply(Roo.bootstrap.ComboBox, {
2493 touchViewTemplate : {
2495 cls: 'modal fade roo-combobox-touch-view',
2499 cls: 'modal-dialog',
2503 cls: 'modal-content',
2505 Roo.bootstrap.ComboBox.header,
2506 Roo.bootstrap.ComboBox.body,
2507 Roo.bootstrap.ComboBox.footer