Ext.ns('Ext.ux.MultiCombo'); /** * Checkable * @plugin */ Ext.ux.MultiCombo.Checkable=function(cfg){ Ext.apply(this, cfg); }; Ext.ux.MultiCombo.Checkable.prototype ={ /** * @cfg {String} checkSelector DomQuery config for locating checkbox */ checkSelector:'input[type=checkbox]', /** * @cfg {String} itemSelector The itemSelector used with Combo's internal DataView [x-combo-list] */ itemSelector :'x-combo-list', /** * @cfg {String} cls */ cls:'combo-checkable', /** * @cfg {String} selectAllText The "SELECT ALL" phrase [Select All] */ selectAllText:'Select All', /** * @cfg {String} clearAllText the text to display for "clear all" link */ clearAllText :'clear all',
/** * @cfg {String} separatorHtml arbitrary html rendered after Checkable controls. Can be used to add an * html separator markup. */ separatorHtml :'',
// private {Boolean} checked checked :null,
init :function(combo){ this.combo = combo; var checkable =this; var id =Ext.id(); var cls = combo.itemSelector ||this.itemSelector;
/** * selectNext Called by MultiCombo. use this to apply hover-class to this row. * @param {Object} sender */ selectNext:function(sender){ sender.view.el.child('.'+this.cls).addClass(sender.highlightClass); },
/** * selectPrev Called by MultiCombo, use this to apply hover class to row. * @param {Object} sender */ selectPrev :function(sender){ sender.view.el.child('.'+this.cls).addClass(sender.highlightClass); },
/** * onEnter Called by MultiCombo * @param {Object} sender */ onEnter :function(sender){ this.setChecked(!this.checked); },
/** * onContainerClick Fired by MultiCombo * @param {Object} dv * @param {Object} ev */ onContainerClick :function(dv, ev){ var btnClearAll = ev.getTarget('.'+this.cls+'-clear-all'); if(btnClearAll){ this.clearAll(); } else{ this.setChecked(!this.checked); } returnfalse; },
// private selectAll selectAll :function(){ var value =[]; this.combo.store.each(function(r){ value.push(r.data[this.combo.valueField]);},this); this.combo.setValue(value); this.combo.selectByValue(this.combo.getValue()); this.combo.focus(); },