* @class Roo.form.ComboCheck
* @extends Roo.form.ComboBox
* A combobox for multiple select items.
+ *
+ * FIXME - could do with a reset button..
+ *
* @constructor
* Create a new ComboCheck
* @param {Object} config Configuration options
if ((typeof(_t[e]) == 'undefined' ) || !_t[e].length) {
throw "Roo.form.ComboCheck : missing value for: " + e;
}
- })
+ });
+
-
};
Roo.extend(Roo.form.ComboCheck, Roo.form.ComboBox, {
},
select: function () {
- Roo.log("SELECT CALLED");
+ //Roo.log("SELECT CALLED");
},
- /*
- onLoad: function() {
- if(!this.hasFocus){
- return;
- }
- if(!this.store.getCount()){
- this.onEmptyResults();
- return;
- }
- this.expand();
- this.restrictHeight();
- //
-
- if(!this.selectByValue(this.value, true)){
- this.select(0, true);
- }
-
-
- },
- */
selectByValue : function(xv, scrollIntoView){
var ar = this.getValueArray();
- var sels = []
+ var sels = [];
- Roo.each(ar, funciton(v) {
- if(v !== undefined && v !== null){
- var r = this.findRecord(this.valueField || this.displayField, v);
- if(r){
- sels.push(this.store.indexOf(r))
-
- }
- })
+ Roo.each(ar, function(v) {
+ if(v === undefined || v === null){
+ return;
+ }
+ var r = this.findRecord(this.valueField, v);
+ if(r){
+ sels.push(this.store.indexOf(r))
+
+ }
+ },this);
+ this.view.select(sels);
return false;
},
onSelect : function(record, index){
- Roo.log("onselect Called");
+ // Roo.log("onselect Called");
// this is only called by the clear button now..
- this.view.clearSelections();
+ this.view.clearSelections();
+ this.setValue('[]');
+ if (this.value != this.valueBefore) {
+ this.fireEvent('change', this, this.value, this.valueBefore);
+ }
},
getValueArray : function()
{
var ar = [] ;
+
try {
+ //Roo.log(this.value);
+ if (typeof(this.value) == 'undefined') {
+ return [];
+ }
var ar = Roo.decode(this.value);
return ar instanceof Array ? ar : []; //?? valid?
}
},
-
+ expand : function ()
+ {
+ Roo.form.ComboCheck.superclass.expand.call(this);
+ this.valueBefore = this.value;
+
+
+ },
collapse : function(){
Roo.form.ComboCheck.superclass.collapse.call(this);
r = st.getAt(i);
nv.push(r.get(this.valueField));
},this);
- this.setValue(Roo.encode(nv))
+ this.setValue(Roo.encode(nv));
+ if (this.value != this.valueBefore) {
+
+ this.fireEvent('change', this, this.value, this.valueBefore);
+ }
},