roojs-ui.js
[roojs1] / Roo / form / ComboCheck.js
index c107cbb..3797916 100644 (file)
@@ -10,6 +10,9 @@
  * @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
@@ -27,7 +30,7 @@ Roo.form.ComboCheck = function(config){
         if ((typeof(_t[e]) == 'undefined' ) || !_t[e].length) {
             throw "Roo.form.ComboCheck : missing value for: " + e;
         }
-    })
+    });
     
     
 };
@@ -84,7 +87,7 @@ Roo.extend(Roo.form.ComboCheck, Roo.form.ComboBox, {
         
     },
     select: function () {
-        Roo.log("SELECT CALLED");
+        //Roo.log("SELECT CALLED");
     },
      
     selectByValue : function(xv, scrollIntoView){
@@ -108,14 +111,23 @@ Roo.extend(Roo.form.ComboCheck, Roo.form.ComboBox, {
     
     
     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?
             
@@ -127,7 +139,7 @@ Roo.extend(Roo.form.ComboCheck, Roo.form.ComboBox, {
     },
     expand : function ()
     {
-        Roo.form.ComboCheck.superclass.setValue.call(this);
+        Roo.form.ComboCheck.superclass.expand.call(this);
         this.valueBefore = this.value;
         
 
@@ -144,9 +156,10 @@ Roo.extend(Roo.form.ComboCheck, Roo.form.ComboBox, {
             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('changed', )
+
+            this.fireEvent('change', this, this.value, this.valueBefore);
         }
         
     },