X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2Fform%2FComboBoxArray.js;h=74a02899fb207182ec6ec387890eaa4b9ec4c9bb;hb=4c028cc735ffaaa41aeaf05ea70dc4810513397d;hp=2dce2a968a8ea207c7628e466939070443b71d96;hpb=7b065e535b01bdbe4fd7d7352f97ae08da66fafc;p=roojs1 diff --git a/Roo/form/ComboBoxArray.js b/Roo/form/ComboBoxArray.js index 2dce2a968a..74a02899fb 100644 --- a/Roo/form/ComboBoxArray.js +++ b/Roo/form/ComboBoxArray.js @@ -36,6 +36,16 @@ Roo.form.ComboBoxArray = function(config) { + this.addEvents({ + /** + * @event remove + * Fires when remove the value from the list + * @param {Roo.form.ComboBox} combo This combo box + */ + 'remove' : true + + + }); Roo.form.ComboBoxArray.superclass.constructor.call(this, config); @@ -335,10 +345,46 @@ Roo.extend(Roo.form.ComboBoxArray, Roo.form.TextField, }, + /** + * Validates the combox array value + * @return {Boolean} True if the value is valid, else false + */ + validate : function(){ + if(this.disabled || this.validateValue(this.processValue(this.getValue()))){ + this.clearInvalid(); + return true; + } + return false; + }, validateValue : function(value){ return Roo.form.ComboBoxArray.superclass.validateValue.call(this, this.getValue()); + }, + + /*@ + * overide + * + */ + isDirty : function() { + if(this.disabled) { + return false; + } + + try { + var d = Roo.decode(String(this.originalValue)); + } catch (e) { + return String(this.getValue()) !== String(this.originalValue); + } + + var originalValue = []; + + for (var i = 0; i < d.length; i++){ + originalValue.push(d[i][this.valueField]); + } + + return String(this.getValue()) !== String(originalValue.join(',')); + } }); @@ -411,24 +457,13 @@ Roo.extend(Roo.form.ComboBoxArray.Item, Roo.BoxComponent, { remove : function() { - + Roo.log(this); this.cb.items.remove(this); this.el.child('img').un('click', this.remove, this); this.el.remove(); this.cb.updateHiddenEl(); - }, - - /** - * Validates the field value - * @return {Boolean} True if the value is valid, else false - */ - validate : function(){ - if(this.disabled || this.validateValue(this.processValue(this.getValue()))){ - this.clearInvalid(); - return true; - } - return false; + + Roo.log('remove?????'); + this.cb.fireEvent('remove', this.cb, this); } - - }); \ No newline at end of file