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
18 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
20 * Create a new ComboBox.
21 * @param {Object} config Configuration options
23 Roo.bootstrap.ComboBox = function(config){
24 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
28 * Fires when the dropdown list is expanded
29 * @param {Roo.bootstrap.ComboBox} combo This combo box
34 * Fires when the dropdown list is collapsed
35 * @param {Roo.bootstrap.ComboBox} combo This combo box
40 * Fires before a list item is selected. Return false to cancel the selection.
41 * @param {Roo.bootstrap.ComboBox} combo This combo box
42 * @param {Roo.data.Record} record The data record returned from the underlying store
43 * @param {Number} index The index of the selected item in the dropdown list
45 'beforeselect' : true,
48 * Fires when a list item is selected
49 * @param {Roo.bootstrap.ComboBox} combo This combo box
50 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
51 * @param {Number} index The index of the selected item in the dropdown list
56 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
57 * The event object passed has these properties:
58 * @param {Roo.bootstrap.ComboBox} combo This combo box
59 * @param {String} query The query
60 * @param {Boolean} forceAll true to force "all" query
61 * @param {Boolean} cancel true to cancel the query
62 * @param {Object} e The query event object
67 * Fires when the 'add' icon is pressed (add a listener to enable add button)
68 * @param {Roo.bootstrap.ComboBox} combo This combo box
73 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
74 * @param {Roo.bootstrap.ComboBox} combo This combo box
75 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
80 * Fires when the remove value from the combobox array
81 * @param {Roo.bootstrap.ComboBox} combo This combo box
85 * @event specialfilter
86 * Fires when specialfilter
87 * @param {Roo.bootstrap.ComboBox} combo This combo box
89 'specialfilter' : true
96 this.selectedIndex = -1;
97 if(this.mode == 'local'){
98 if(config.queryDelay === undefined){
101 if(config.minChars === undefined){
107 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
110 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
111 * rendering into an Roo.Editor, defaults to false)
114 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
115 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
118 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
121 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
122 * the dropdown list (defaults to undefined, with no header element)
126 * @cfg {String/Roo.Template} tpl The template to use to render the output
130 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
132 listWidth: undefined,
134 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
135 * mode = 'remote' or 'text' if mode = 'local')
137 displayField: undefined,
140 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
141 * mode = 'remote' or 'value' if mode = 'local').
142 * Note: use of a valueField requires the user make a selection
143 * in order for a value to be mapped.
145 valueField: undefined,
149 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
150 * field's data value (defaults to the underlying DOM element's name)
152 hiddenName: undefined,
154 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
158 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
160 selectedClass: 'active',
163 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
167 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
168 * anchor positions (defaults to 'tl-bl')
172 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
176 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
177 * query specified by the allQuery config option (defaults to 'query')
179 triggerAction: 'query',
181 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
182 * (defaults to 4, does not apply if editable = false)
186 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
187 * delay (typeAheadDelay) if it matches a known value (defaults to false)
191 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
192 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
196 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
197 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
201 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
202 * when editable = true (defaults to false)
206 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
210 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
211 * when mode = 'remote' (defaults to 'Loading...')
213 loadingText: 'Loading...',
215 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
219 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
223 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
224 * traditional select (defaults to true)
228 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
232 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
236 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
237 * listWidth has a higher value)
241 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
242 * allow the user to set arbitrary text into the field (defaults to false)
244 forceSelection:false,
246 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
247 * if typeAhead = true (defaults to 250)
249 typeAheadDelay : 250,
251 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
252 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
254 valueNotFoundText : undefined,
256 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
261 * @cfg {Boolean} disableClear Disable showing of clear button.
263 disableClear : false,
265 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
270 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
275 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
277 invalidClass : "has-warning",
280 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
282 validClass : "has-success",
285 * @cfg {Boolean} specialFilter (true|false) special filter default false
287 specialFilter : false,
290 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
292 mobileTouchView : true,
304 btnPosition : 'right',
306 showToggleBtn : true,
308 emptyResultText: 'Empty',
309 triggerText : 'Select',
311 // element that contains real text value.. (when hidden is used..)
313 getAutoCreate : function()
321 if(Roo.isTouch && this.mobileTouchView){
322 cfg = this.getAutoCreateTouchView();
330 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
335 * ComboBox with tickable selections
338 var align = this.labelAlign || this.parentLabelAlign();
341 cls : 'form-group roo-combobox-tickable' //input-group
346 cls : 'tickable-buttons',
351 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
358 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
365 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
374 cls: 'select2-search-field-input'
380 Roo.each(buttons.cn, function(c){
382 c.cls += ' btn-' + _this.size;
385 if (_this.disabled) {
396 cls: 'form-hidden-field'
400 cls: 'select2-choices',
404 cls: 'select2-search-field',
416 cls: 'select2-container input-group select2-container-multi',
421 // cls: 'typeahead typeahead-long dropdown-menu',
422 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
427 if(this.hasFeedback && !this.allowBlank){
431 cls: 'glyphicon form-control-feedback'
434 combobox.cn.push(feedback);
437 if (align ==='left' && this.fieldLabel.length) {
439 Roo.log("left and has label");
445 cls : 'control-label col-sm-' + this.labelWidth,
446 html : this.fieldLabel
450 cls : "col-sm-" + (12 - this.labelWidth),
457 } else if ( this.fieldLabel.length) {
463 //cls : 'input-group-addon',
464 html : this.fieldLabel
474 Roo.log(" no label && no align");
481 ['xs','sm','md','lg'].map(function(size){
482 if (settings[size]) {
483 cfg.cls += ' col-' + size + '-' + settings[size];
491 _initEventsCalled : false,
494 initEvents: function()
497 if (this._initEventsCalled) { // as we call render... prevent looping...
500 this._initEventsCalled = true;
503 throw "can not find store for combo";
506 this.store = Roo.factory(this.store, Roo.data);
508 // if we are building from html. then this element is so complex, that we can not really
509 // use the rendered HTML.
510 // so we have to trash and replace the previous code.
511 if (Roo.XComponent.build_from_html) {
513 // remove this element....
514 var e = this.el.dom, k=0;
515 while (e ) { e = e.previousSibling; ++k;}
520 this.rendered = false;
522 this.render(this.parent().getChildContainer(true), k);
533 if(Roo.isTouch && this.mobileTouchView){
534 this.initTouchView();
539 this.initTickableEvents();
543 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
547 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
549 this.hiddenField.dom.value =
550 this.hiddenValue !== undefined ? this.hiddenValue :
551 this.value !== undefined ? this.value : '';
553 // prevent input submission
554 this.el.dom.removeAttribute('name');
555 this.hiddenField.dom.setAttribute('name', this.hiddenName);
560 // this.el.dom.setAttribute('autocomplete', 'off');
563 var cls = 'x-combo-list';
565 //this.list = new Roo.Layer({
566 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
572 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
573 _this.list.setWidth(lw);
576 this.list.on('mouseover', this.onViewOver, this);
577 this.list.on('mousemove', this.onViewMove, this);
579 this.list.on('scroll', this.onViewScroll, this);
582 this.list.swallowEvent('mousewheel');
583 this.assetHeight = 0;
586 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
587 this.assetHeight += this.header.getHeight();
590 this.innerList = this.list.createChild({cls:cls+'-inner'});
591 this.innerList.on('mouseover', this.onViewOver, this);
592 this.innerList.on('mousemove', this.onViewMove, this);
593 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
595 if(this.allowBlank && !this.pageSize && !this.disableClear){
596 this.footer = this.list.createChild({cls:cls+'-ft'});
597 this.pageTb = new Roo.Toolbar(this.footer);
601 this.footer = this.list.createChild({cls:cls+'-ft'});
602 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
603 {pageSize: this.pageSize});
607 if (this.pageTb && this.allowBlank && !this.disableClear) {
609 this.pageTb.add(new Roo.Toolbar.Fill(), {
610 cls: 'x-btn-icon x-btn-clear',
616 _this.onSelect(false, -1);
621 this.assetHeight += this.footer.getHeight();
626 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
629 this.view = new Roo.View(this.list, this.tpl, {
630 singleSelect:true, store: this.store, selectedClass: this.selectedClass
632 //this.view.wrapEl.setDisplayed(false);
633 this.view.on('click', this.onViewClick, this);
637 this.store.on('beforeload', this.onBeforeLoad, this);
638 this.store.on('load', this.onLoad, this);
639 this.store.on('loadexception', this.onLoadException, this);
642 this.resizer = new Roo.Resizable(this.list, {
643 pinned:true, handles:'se'
645 this.resizer.on('resize', function(r, w, h){
646 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
648 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
649 this.restrictHeight();
651 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
655 this.editable = true;
656 this.setEditable(false);
661 if (typeof(this.events.add.listeners) != 'undefined') {
663 this.addicon = this.wrap.createChild(
664 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
666 this.addicon.on('click', function(e) {
667 this.fireEvent('add', this);
670 if (typeof(this.events.edit.listeners) != 'undefined') {
672 this.editicon = this.wrap.createChild(
673 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
675 this.editicon.setStyle('margin-left', '40px');
677 this.editicon.on('click', function(e) {
679 // we fire even if inothing is selected..
680 this.fireEvent('edit', this, this.lastData );
686 this.keyNav = new Roo.KeyNav(this.inputEl(), {
688 this.inKeyMode = true;
692 "down" : function(e){
693 if(!this.isExpanded()){
694 this.onTriggerClick();
696 this.inKeyMode = true;
701 "enter" : function(e){
702 // this.onViewClick();
706 if(this.fireEvent("specialkey", this, e)){
707 this.onViewClick(false);
720 if(this.fireEvent("specialkey", this, e)){
721 this.onViewClick(false);
729 doRelay : function(foo, bar, hname){
730 if(hname == 'down' || this.scope.isExpanded()){
731 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
740 this.queryDelay = Math.max(this.queryDelay || 10,
741 this.mode == 'local' ? 10 : 250);
744 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
747 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
749 if(this.editable !== false){
750 this.inputEl().on("keyup", this.onKeyUp, this);
752 if(this.forceSelection){
753 this.inputEl().on('blur', this.doForce, this);
757 this.choices = this.el.select('ul.select2-choices', true).first();
758 this.searchField = this.el.select('ul li.select2-search-field', true).first();
762 initTickableEvents: function()
768 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
770 this.hiddenField.dom.value =
771 this.hiddenValue !== undefined ? this.hiddenValue :
772 this.value !== undefined ? this.value : '';
774 // prevent input submission
775 this.el.dom.removeAttribute('name');
776 this.hiddenField.dom.setAttribute('name', this.hiddenName);
781 // this.list = this.el.select('ul.dropdown-menu',true).first();
783 this.choices = this.el.select('ul.select2-choices', true).first();
784 this.searchField = this.el.select('ul li.select2-search-field', true).first();
785 if(this.triggerList){
786 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
789 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
790 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
792 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
793 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
795 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
796 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
798 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
799 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
800 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
803 this.cancelBtn.hide();
808 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
809 _this.list.setWidth(lw);
812 this.list.on('mouseover', this.onViewOver, this);
813 this.list.on('mousemove', this.onViewMove, this);
815 this.list.on('scroll', this.onViewScroll, this);
818 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>';
821 this.view = new Roo.View(this.list, this.tpl, {
822 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
825 //this.view.wrapEl.setDisplayed(false);
826 this.view.on('click', this.onViewClick, this);
830 this.store.on('beforeload', this.onBeforeLoad, this);
831 this.store.on('load', this.onLoad, this);
832 this.store.on('loadexception', this.onLoadException, this);
835 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
837 this.inKeyMode = true;
841 "down" : function(e){
842 this.inKeyMode = true;
846 "enter" : function(e){
847 if(this.fireEvent("specialkey", this, e)){
848 this.onViewClick(false);
855 this.onTickableFooterButtonClick(e, false, false);
859 this.fireEvent("specialkey", this, e);
861 this.onTickableFooterButtonClick(e, false, false);
868 doRelay : function(e, fn, key){
869 if(this.scope.isExpanded()){
870 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
879 this.queryDelay = Math.max(this.queryDelay || 10,
880 this.mode == 'local' ? 10 : 250);
883 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
886 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
889 if(this.editable !== false){
890 this.tickableInputEl().on("keyup", this.onKeyUp, this);
895 onDestroy : function(){
897 this.view.setStore(null);
898 this.view.el.removeAllListeners();
899 this.view.el.remove();
900 this.view.purgeListeners();
903 this.list.dom.innerHTML = '';
907 this.store.un('beforeload', this.onBeforeLoad, this);
908 this.store.un('load', this.onLoad, this);
909 this.store.un('loadexception', this.onLoadException, this);
911 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
915 fireKey : function(e){
916 if(e.isNavKeyPress() && !this.list.isVisible()){
917 this.fireEvent("specialkey", this, e);
922 onResize: function(w, h){
923 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
925 // if(typeof w != 'number'){
926 // // we do not handle it!?!?
929 // var tw = this.trigger.getWidth();
930 // // tw += this.addicon ? this.addicon.getWidth() : 0;
931 // // tw += this.editicon ? this.editicon.getWidth() : 0;
933 // this.inputEl().setWidth( this.adjustWidth('input', x));
935 // //this.trigger.setStyle('left', x+'px');
937 // if(this.list && this.listWidth === undefined){
938 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
939 // this.list.setWidth(lw);
940 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
948 * Allow or prevent the user from directly editing the field text. If false is passed,
949 * the user will only be able to select from the items defined in the dropdown list. This method
950 * is the runtime equivalent of setting the 'editable' config option at config time.
951 * @param {Boolean} value True to allow the user to directly edit the field text
953 setEditable : function(value){
954 if(value == this.editable){
957 this.editable = value;
959 this.inputEl().dom.setAttribute('readOnly', true);
960 this.inputEl().on('mousedown', this.onTriggerClick, this);
961 this.inputEl().addClass('x-combo-noedit');
963 this.inputEl().dom.setAttribute('readOnly', false);
964 this.inputEl().un('mousedown', this.onTriggerClick, this);
965 this.inputEl().removeClass('x-combo-noedit');
971 onBeforeLoad : function(combo,opts){
976 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
978 this.restrictHeight();
979 this.selectedIndex = -1;
985 this.hasQuery = false;
991 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
995 if(this.store.getCount() > 0){
997 this.restrictHeight();
998 if(this.lastQuery == this.allQuery){
999 if(this.editable && !this.tickable){
1000 this.inputEl().dom.select();
1004 !this.selectByValue(this.value, true) &&
1007 !this.store.lastOptions ||
1008 typeof(this.store.lastOptions.add) == 'undefined' ||
1009 this.store.lastOptions.add != true
1012 this.select(0, true);
1018 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
1019 this.taTask.delay(this.typeAheadDelay);
1023 this.onEmptyResults();
1029 onLoadException : function()
1031 this.hasQuery = false;
1033 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
1034 this.loading.hide();
1037 if(this.tickable && this.editable){
1043 Roo.log(this.store.reader.jsonData);
1044 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
1046 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
1052 onTypeAhead : function(){
1053 if(this.store.getCount() > 0){
1054 var r = this.store.getAt(0);
1055 var newValue = r.data[this.displayField];
1056 var len = newValue.length;
1057 var selStart = this.getRawValue().length;
1059 if(selStart != len){
1060 this.setRawValue(newValue);
1061 this.selectText(selStart, newValue.length);
1067 onSelect : function(record, index){
1069 if(this.fireEvent('beforeselect', this, record, index) !== false){
1071 this.setFromData(index > -1 ? record.data : false);
1074 this.fireEvent('select', this, record, index);
1079 * Returns the currently selected field value or empty string if no value is set.
1080 * @return {String} value The selected value
1082 getValue : function(){
1085 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
1088 if(this.valueField){
1089 return typeof this.value != 'undefined' ? this.value : '';
1091 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
1096 * Clears any text/value currently set in the field
1098 clearValue : function(){
1099 if(this.hiddenField){
1100 this.hiddenField.dom.value = '';
1103 this.setRawValue('');
1104 this.lastSelectionText = '';
1105 this.lastData = false;
1107 var close = this.closeTriggerEl();
1116 * Sets the specified value into the field. If the value finds a match, the corresponding record text
1117 * will be displayed in the field. If the value does not match the data value of an existing item,
1118 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
1119 * Otherwise the field will be blank (although the value will still be set).
1120 * @param {String} value The value to match
1122 setValue : function(v){
1129 if(this.valueField){
1130 var r = this.findRecord(this.valueField, v);
1132 text = r.data[this.displayField];
1133 }else if(this.valueNotFoundText !== undefined){
1134 text = this.valueNotFoundText;
1137 this.lastSelectionText = text;
1138 if(this.hiddenField){
1139 this.hiddenField.dom.value = v;
1141 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
1144 var close = this.closeTriggerEl();
1147 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
1151 * @property {Object} the last set data for the element
1156 * Sets the value of the field based on a object which is related to the record format for the store.
1157 * @param {Object} value the value to set as. or false on reset?
1159 setFromData : function(o){
1166 var dv = ''; // display value
1167 var vv = ''; // value value..
1169 if (this.displayField) {
1170 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
1172 // this is an error condition!!!
1173 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
1176 if(this.valueField){
1177 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
1180 var close = this.closeTriggerEl();
1183 (vv.length || vv * 1 > 0) ? close.show() : close.hide();
1186 if(this.hiddenField){
1187 this.hiddenField.dom.value = vv;
1189 this.lastSelectionText = dv;
1190 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
1194 // no hidden field.. - we store the value in 'value', but still display
1195 // display field!!!!
1196 this.lastSelectionText = dv;
1197 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
1205 // overridden so that last data is reset..
1212 this.setValue(this.originalValue);
1213 this.clearInvalid();
1214 this.lastData = false;
1216 this.view.clearSelections();
1220 findRecord : function(prop, value){
1222 if(this.store.getCount() > 0){
1223 this.store.each(function(r){
1224 if(r.data[prop] == value){
1236 // returns hidden if it's set..
1237 if (!this.rendered) {return ''};
1238 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
1242 onViewMove : function(e, t){
1243 this.inKeyMode = false;
1247 onViewOver : function(e, t){
1248 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
1251 var item = this.view.findItemFromChild(t);
1254 var index = this.view.indexOf(item);
1255 this.select(index, false);
1260 onViewClick : function(view, doFocus, el, e)
1262 var index = this.view.getSelectedIndexes()[0];
1264 var r = this.store.getAt(index);
1268 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
1275 Roo.each(this.tickItems, function(v,k){
1277 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
1278 _this.tickItems.splice(k, 1);
1280 if(typeof(e) == 'undefined' && view == false){
1281 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
1293 this.tickItems.push(r.data);
1295 if(typeof(e) == 'undefined' && view == false){
1296 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
1303 this.onSelect(r, index);
1305 if(doFocus !== false && !this.blockFocus){
1306 this.inputEl().focus();
1311 restrictHeight : function(){
1312 //this.innerList.dom.style.height = '';
1313 //var inner = this.innerList.dom;
1314 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
1315 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
1316 //this.list.beginUpdate();
1317 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
1318 this.list.alignTo(this.inputEl(), this.listAlign);
1319 this.list.alignTo(this.inputEl(), this.listAlign);
1320 //this.list.endUpdate();
1324 onEmptyResults : function(){
1326 if(this.tickable && this.editable){
1327 this.restrictHeight();
1335 * Returns true if the dropdown list is expanded, else false.
1337 isExpanded : function(){
1338 return this.list.isVisible();
1342 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
1343 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1344 * @param {String} value The data value of the item to select
1345 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1346 * selected item if it is not currently in view (defaults to true)
1347 * @return {Boolean} True if the value matched an item in the list, else false
1349 selectByValue : function(v, scrollIntoView){
1350 if(v !== undefined && v !== null){
1351 var r = this.findRecord(this.valueField || this.displayField, v);
1353 this.select(this.store.indexOf(r), scrollIntoView);
1361 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
1362 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1363 * @param {Number} index The zero-based index of the list item to select
1364 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1365 * selected item if it is not currently in view (defaults to true)
1367 select : function(index, scrollIntoView){
1368 this.selectedIndex = index;
1369 this.view.select(index);
1370 if(scrollIntoView !== false){
1371 var el = this.view.getNode(index);
1373 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
1376 this.list.scrollChildIntoView(el, false);
1382 selectNext : function(){
1383 var ct = this.store.getCount();
1385 if(this.selectedIndex == -1){
1387 }else if(this.selectedIndex < ct-1){
1388 this.select(this.selectedIndex+1);
1394 selectPrev : function(){
1395 var ct = this.store.getCount();
1397 if(this.selectedIndex == -1){
1399 }else if(this.selectedIndex != 0){
1400 this.select(this.selectedIndex-1);
1406 onKeyUp : function(e){
1407 if(this.editable !== false && !e.isSpecialKey()){
1408 this.lastKey = e.getKey();
1409 this.dqTask.delay(this.queryDelay);
1414 validateBlur : function(){
1415 return !this.list || !this.list.isVisible();
1419 initQuery : function(){
1421 var v = this.getRawValue();
1423 if(this.tickable && this.editable){
1424 v = this.tickableInputEl().getValue();
1431 doForce : function(){
1432 if(this.inputEl().dom.value.length > 0){
1433 this.inputEl().dom.value =
1434 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
1440 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
1441 * query allowing the query action to be canceled if needed.
1442 * @param {String} query The SQL query to execute
1443 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
1444 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
1445 * saved in the current store (defaults to false)
1447 doQuery : function(q, forceAll){
1449 if(q === undefined || q === null){
1458 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
1463 forceAll = qe.forceAll;
1464 if(forceAll === true || (q.length >= this.minChars)){
1466 this.hasQuery = true;
1468 if(this.lastQuery != q || this.alwaysQuery){
1470 if(this.mode == 'local'){
1471 this.selectedIndex = -1;
1473 this.store.clearFilter();
1476 if(this.specialFilter){
1477 this.fireEvent('specialfilter', this);
1482 this.store.filter(this.displayField, q);
1485 this.store.fireEvent("datachanged", this.store);
1492 this.store.baseParams[this.queryParam] = q;
1494 var options = {params : this.getParams(q)};
1498 options.params.start = this.page * this.pageSize;
1501 this.store.load(options);
1504 * this code will make the page width larger, at the beginning, the list not align correctly,
1505 * we should expand the list on onLoad
1511 this.selectedIndex = -1;
1516 this.loadNext = false;
1520 getParams : function(q){
1522 //p[this.queryParam] = q;
1526 p.limit = this.pageSize;
1532 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
1534 collapse : function(){
1535 if(!this.isExpanded()){
1542 this.hasFocus = false;
1544 this.cancelBtn.hide();
1545 this.trigger.show();
1548 this.tickableInputEl().dom.value = '';
1549 this.tickableInputEl().blur();
1554 Roo.get(document).un('mousedown', this.collapseIf, this);
1555 Roo.get(document).un('mousewheel', this.collapseIf, this);
1556 if (!this.editable) {
1557 Roo.get(document).un('keydown', this.listKeyPress, this);
1559 this.fireEvent('collapse', this);
1563 collapseIf : function(e){
1564 var in_combo = e.within(this.el);
1565 var in_list = e.within(this.list);
1566 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
1568 if (in_combo || in_list || is_list) {
1569 //e.stopPropagation();
1574 this.onTickableFooterButtonClick(e, false, false);
1582 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
1584 expand : function(){
1586 if(this.isExpanded() || !this.hasFocus){
1590 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
1591 this.list.setWidth(lw);
1598 this.restrictHeight();
1602 this.tickItems = Roo.apply([], this.item);
1605 this.cancelBtn.show();
1606 this.trigger.hide();
1609 this.tickableInputEl().focus();
1614 Roo.get(document).on('mousedown', this.collapseIf, this);
1615 Roo.get(document).on('mousewheel', this.collapseIf, this);
1616 if (!this.editable) {
1617 Roo.get(document).on('keydown', this.listKeyPress, this);
1620 this.fireEvent('expand', this);
1624 // Implements the default empty TriggerField.onTriggerClick function
1625 onTriggerClick : function(e)
1627 Roo.log('trigger click');
1629 if(this.disabled || !this.triggerList){
1634 this.loadNext = false;
1636 if(this.isExpanded()){
1638 if (!this.blockFocus) {
1639 this.inputEl().focus();
1643 this.hasFocus = true;
1644 if(this.triggerAction == 'all') {
1645 this.doQuery(this.allQuery, true);
1647 this.doQuery(this.getRawValue());
1649 if (!this.blockFocus) {
1650 this.inputEl().focus();
1655 onTickableTriggerClick : function(e)
1662 this.loadNext = false;
1663 this.hasFocus = true;
1665 if(this.triggerAction == 'all') {
1666 this.doQuery(this.allQuery, true);
1668 this.doQuery(this.getRawValue());
1672 onSearchFieldClick : function(e)
1674 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
1675 this.onTickableFooterButtonClick(e, false, false);
1679 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
1684 this.loadNext = false;
1685 this.hasFocus = true;
1687 if(this.triggerAction == 'all') {
1688 this.doQuery(this.allQuery, true);
1690 this.doQuery(this.getRawValue());
1694 listKeyPress : function(e)
1696 //Roo.log('listkeypress');
1697 // scroll to first matching element based on key pres..
1698 if (e.isSpecialKey()) {
1701 var k = String.fromCharCode(e.getKey()).toUpperCase();
1704 var csel = this.view.getSelectedNodes();
1705 var cselitem = false;
1707 var ix = this.view.indexOf(csel[0]);
1708 cselitem = this.store.getAt(ix);
1709 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
1715 this.store.each(function(v) {
1717 // start at existing selection.
1718 if (cselitem.id == v.id) {
1724 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
1725 match = this.store.indexOf(v);
1731 if (match === false) {
1732 return true; // no more action?
1735 this.view.select(match);
1736 var sn = Roo.get(this.view.getSelectedNodes()[0])
1737 sn.scrollIntoView(sn.dom.parentNode, false);
1740 onViewScroll : function(e, t){
1742 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){
1746 this.hasQuery = true;
1748 this.loading = this.list.select('.loading', true).first();
1750 if(this.loading === null){
1751 this.list.createChild({
1753 cls: 'loading select2-more-results select2-active',
1754 html: 'Loading more results...'
1757 this.loading = this.list.select('.loading', true).first();
1759 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
1761 this.loading.hide();
1764 this.loading.show();
1769 this.loadNext = true;
1771 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
1776 addItem : function(o)
1778 var dv = ''; // display value
1780 if (this.displayField) {
1781 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
1783 // this is an error condition!!!
1784 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
1791 var choice = this.choices.createChild({
1793 cls: 'select2-search-choice',
1802 cls: 'select2-search-choice-close',
1807 }, this.searchField);
1809 var close = choice.select('a.select2-search-choice-close', true).first()
1811 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
1819 this.inputEl().dom.value = '';
1824 onRemoveItem : function(e, _self, o)
1828 this.lastItem = Roo.apply([], this.item);
1830 var index = this.item.indexOf(o.data) * 1;
1833 Roo.log('not this item?!');
1837 this.item.splice(index, 1);
1842 this.fireEvent('remove', this, e);
1848 syncValue : function()
1850 if(!this.item.length){
1857 Roo.each(this.item, function(i){
1858 if(_this.valueField){
1859 value.push(i[_this.valueField]);
1866 this.value = value.join(',');
1868 if(this.hiddenField){
1869 this.hiddenField.dom.value = this.value;
1872 this.store.fireEvent("datachanged", this.store);
1875 clearItem : function()
1883 Roo.each(this.choices.select('>li.select2-search-choice', true).elements, function(c){
1891 if(this.tickable && !Roo.isTouch){
1892 this.view.refresh();
1896 inputEl: function ()
1898 if(Roo.isTouch && this.mobileTouchView){
1899 return this.el.select('input.form-control',true).first();
1903 return this.searchField;
1906 return this.el.select('input.form-control',true).first();
1910 onTickableFooterButtonClick : function(e, btn, el)
1914 this.lastItem = Roo.apply([], this.item);
1916 if(btn && btn.name == 'cancel'){
1917 this.tickItems = Roo.apply([], this.item);
1926 Roo.each(this.tickItems, function(o){
1934 validate : function()
1936 var v = this.getRawValue();
1939 v = this.getValue();
1942 if(this.disabled || this.allowBlank || v.length){
1951 tickableInputEl : function()
1953 if(!this.tickable || !this.editable){
1954 return this.inputEl();
1957 return this.inputEl().select('.select2-search-field-input', true).first();
1961 getAutoCreateTouchView : function()
1966 cls: 'form-group' //input-group
1972 type : this.inputType,
1973 cls : 'form-control x-combo-noedit',
1974 autocomplete: 'new-password',
1975 placeholder : this.placeholder || '',
1980 input.name = this.name;
1984 input.cls += ' input-' + this.size;
1987 if (this.disabled) {
1988 input.disabled = true;
1999 inputblock.cls += ' input-group';
2001 inputblock.cn.unshift({
2003 cls : 'input-group-addon',
2008 if(this.removable && !this.multiple){
2009 inputblock.cls += ' roo-removable';
2011 inputblock.cn.push({
2014 cls : 'roo-combo-removable-btn close'
2018 if(this.hasFeedback && !this.allowBlank){
2020 inputblock.cls += ' has-feedback';
2022 inputblock.cn.push({
2024 cls: 'glyphicon form-control-feedback'
2031 inputblock.cls += (this.before) ? '' : ' input-group';
2033 inputblock.cn.push({
2035 cls : 'input-group-addon',
2046 cls: 'form-hidden-field'
2060 cls: 'form-hidden-field'
2064 cls: 'select2-choices',
2068 cls: 'select2-search-field',
2081 cls: 'select2-container input-group',
2088 combobox.cls += ' select2-container-multi';
2091 var align = this.labelAlign || this.parentLabelAlign();
2095 if(this.fieldLabel.length){
2097 var lw = align === 'left' ? ('col-sm' + this.labelWidth) : '';
2098 var cw = align === 'left' ? ('col-sm' + (12 - this.labelWidth)) : '';
2103 cls : 'control-label ' + lw,
2104 html : this.fieldLabel
2116 var settings = this;
2118 ['xs','sm','md','lg'].map(function(size){
2119 if (settings[size]) {
2120 cfg.cls += ' col-' + size + '-' + settings[size];
2127 initTouchView : function()
2129 this.renderTouchView();
2131 this.touchViewEl.on('scroll', function(){
2132 this.el.dom.scrollTop = 0;
2135 this.inputEl().on("click", this.showTouchView, this);
2136 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
2137 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
2139 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
2141 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
2142 this.store.on('load', this.onTouchViewLoad, this);
2143 this.store.on('loadexception', this.onTouchViewLoadException, this);
2145 if(this.hiddenName){
2147 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
2149 this.hiddenField.dom.value =
2150 this.hiddenValue !== undefined ? this.hiddenValue :
2151 this.value !== undefined ? this.value : '';
2153 this.el.dom.removeAttribute('name');
2154 this.hiddenField.dom.setAttribute('name', this.hiddenName);
2158 this.choices = this.el.select('ul.select2-choices', true).first();
2159 this.searchField = this.el.select('ul li.select2-search-field', true).first();
2162 if(this.removable && !this.multiple){
2163 var close = this.closeTriggerEl();
2165 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
2166 close.on('click', this.removeBtnClick, this, close);
2175 renderTouchView : function()
2177 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
2178 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2180 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
2181 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2183 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
2184 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2185 this.touchViewBodyEl.setStyle('overflow', 'auto');
2187 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
2188 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2190 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
2191 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2195 showTouchView : function()
2197 this.touchViewHeaderEl.hide();
2199 if(this.fieldLabel.length){
2200 this.touchViewHeaderEl.dom.innerHTML = this.fieldLabel;
2201 this.touchViewHeaderEl.show();
2204 this.touchViewEl.show();
2206 this.touchViewEl.select('.modal-dialog', true).first().setStyle('margin', '0px');
2207 this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2209 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
2211 if(this.fieldLabel.length){
2212 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
2215 this.touchViewBodyEl.setHeight(bodyHeight);
2219 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
2221 this.touchViewEl.addClass('in');
2224 this.doTouchViewQuery();
2228 hideTouchView : function()
2230 this.touchViewEl.removeClass('in');
2234 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
2236 this.touchViewEl.setStyle('display', 'none');
2241 setTouchViewValue : function()
2248 Roo.each(this.tickItems, function(o){
2253 this.hideTouchView();
2256 doTouchViewQuery : function()
2265 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
2269 if(!this.alwaysQuery || this.mode == 'local'){
2270 this.onTouchViewLoad();
2277 onTouchViewBeforeLoad : function(combo,opts)
2283 onTouchViewLoad : function()
2285 if(this.store.getCount() < 1){
2286 this.onTouchViewEmptyResults();
2290 this.clearTouchView();
2292 var rawValue = this.getRawValue();
2294 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
2296 this.tickItems = [];
2298 this.store.data.each(function(d, rowIndex){
2299 var row = this.touchViewListGroup.createChild(template);
2301 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
2302 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = d.data[this.displayField];
2305 if(!this.multiple && this.valueField && typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue()){
2306 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2309 if(this.multiple && this.valueField && typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1){
2310 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2311 this.tickItems.push(d.data);
2314 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
2318 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
2320 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
2322 if(this.fieldLabel.length){
2323 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
2326 var listHeight = this.touchViewListGroup.getHeight();
2330 if(firstChecked && listHeight > bodyHeight){
2331 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
2336 onTouchViewLoadException : function()
2338 this.hideTouchView();
2341 onTouchViewEmptyResults : function()
2343 this.clearTouchView();
2345 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
2347 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
2351 clearTouchView : function()
2353 this.touchViewListGroup.dom.innerHTML = '';
2356 onTouchViewClick : function(e, el, o)
2361 var rowIndex = o.rowIndex;
2363 var r = this.store.getAt(rowIndex);
2366 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
2367 c.dom.removeAttribute('checked');
2370 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2372 this.setFromData(r.data);
2374 var close = this.closeTriggerEl();
2380 this.hideTouchView();
2382 this.fireEvent('select', this, r, rowIndex);
2387 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
2388 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
2389 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
2393 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
2394 this.addItem(r.data);
2395 this.tickItems.push(r.data);
2401 * @cfg {Boolean} grow
2405 * @cfg {Number} growMin
2409 * @cfg {Number} growMax
2418 Roo.apply(Roo.bootstrap.ComboBox, {
2422 cls: 'modal-header',
2444 cls: 'list-group-item',
2448 cls: 'roo-combobox-list-group-item-value'
2452 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
2466 listItemCheckbox : {
2468 cls: 'list-group-item',
2472 cls: 'roo-combobox-list-group-item-value'
2476 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
2492 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
2497 cls: 'modal-footer',
2505 cls: 'col-xs-6 text-left',
2508 cls: 'btn btn-danger roo-touch-view-cancel',
2514 cls: 'col-xs-6 text-right',
2517 cls: 'btn btn-success roo-touch-view-ok',
2528 Roo.apply(Roo.bootstrap.ComboBox, {
2530 touchViewTemplate : {
2532 cls: 'modal fade roo-combobox-touch-view',
2536 cls: 'modal-dialog',
2540 cls: 'modal-content',
2542 Roo.bootstrap.ComboBox.header,
2543 Roo.bootstrap.ComboBox.body,
2544 Roo.bootstrap.ComboBox.footer