X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6b044c28b5f26fb99c86c237ffad19741c0f7f3d:/docs/source/CheckboxGroup.html?ds=sidebyside diff --git a/docs/source/CheckboxGroup.html b/docs/source/CheckboxGroup.html index b0b8c289..2ab28aca 100644 --- a/docs/source/CheckboxGroup.html +++ b/docs/source/CheckboxGroup.html @@ -1,11 +1,18 @@ - -
-/** + + + +The source code + + + + +/*! + * Ext JS Library 3.3.1 + * Copyright(c) 2006-2010 Sencha Inc. + * licensing@sencha.com + * http://www.sencha.com/license + */ +/** * @class Ext.form.CheckboxGroup * @extends Ext.form.Field *A grouping container for {@link Ext.form.Checkbox} controls.
@@ -40,7 +47,7 @@ Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, { * checkbox/radio controls using automatic layout. This config can take several types of values: *
The controls will be rendered one per column on one row and the width * of each column will be evenly distributed based on the width of the overall field container. This is the default.
If you specific a number (e.g., 3) that number of columns will be + *
If you specific a number (e.g., 3) that number of columns will be * created and the contained controls will be automatically distributed based on the value of {@link #vertical}.
You can also specify an array of column widths, mixing integer * (fixed width) and float (percentage width) values as needed (e.g., [100, .25, .75]). Any integer values will @@ -50,7 +57,7 @@ Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, { */ columns : 'auto',
/** - * @cfg {Boolean} vertical True to distribute contained controls across columns, completely filling each column + * @cfg {Boolean} vertical True to distribute contained controls across columns, completely filling each column * top to bottom before starting on the next column. The number of controls in each column will be automatically * calculated to keep columns as even as possible. The default value is false, so that controls will be added * to columns one at a time, completely filling each row left to right before starting on the next row. @@ -62,17 +69,17 @@ Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, { */ allowBlank : true, /** - * @cfg {String} blankText Error text to display if the {@link #allowBlank} validation fails (defaults to "You must + * @cfg {String} blankText Error text to display if the {@link #allowBlank} validation fails (defaults to "You must * select at least one item in this group") */ blankText : "You must select at least one item in this group", - + // private defaultType : 'checkbox', - + // private groupCls : 'x-form-check-group', - + // private initComponent: function(){ this.addEvents( @@ -83,33 +90,37 @@ Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, { * @param {Array} checked An array containing the checked boxes. */ 'change' - ); + ); + this.on('change', this.validate, this); Ext.form.CheckboxGroup.superclass.initComponent.call(this); }, - + // private onRender : function(ct, position){ if(!this.el){ var panelCfg = { + autoEl: { + id: this.id + }, cls: this.groupCls, layout: 'column', - border: false, - renderTo: ct + renderTo: ct, + bufferResize: false // Default this to false, since it doesn't really have a proper ownerCt. }; var colCfg = { + xtype: 'container', defaultType: this.defaultType, layout: 'form', - border: false, defaults: { hideLabel: true, anchor: '100%' } }; - + if(this.items[0].items){ - + // The container has standard ColumnLayout configs, so pass them in directly - + Ext.apply(panelCfg, { layoutConfig: {columns: this.items.length}, defaults: this.defaults, @@ -118,14 +129,14 @@ Ext.form.CheckboxGroup = Ext.extend(Ext.form.Field, { for(var i=0, len=this.items.length; i
// call with name and value
myCheckboxGroup.setValue('cb-col-1', true);
-// call with an array of boolean values
+// call with an array of boolean values
myCheckboxGroup.setValue([true, false, false]);
// call with an object literal specifying item:value pairs
myCheckboxGroup.setValue({
@@ -306,47 +367,74 @@ myCheckboxGroup.setValue('cb-col-1,cb-col-3');
* @param {Boolean} value (optional) The value to set the item.
* @return {Ext.form.CheckboxGroup} this
*/
- setValue : function(id, value){
+ setValue: function(){
if(this.rendered){
- if(arguments.length == 1){
- if(Ext.isArray(id)){
- //an array of boolean values
- Ext.each(id, function(val, idx){
+ this.onSetValue.apply(this, arguments);
+ }else{
+ this.buffered = true;
+ this.value = arguments;
+ }
+ return this;
+ },
+
+ /**
+ * @private
+ * Sets the values of one or more of the items within the CheckboxGroup
+ * @param {String|Array|Object} id Can take multiple forms. Can be optionally:
+ *
+ * - An ID string to be used with a second argument
+ * - An array of the form ['some', 'list', 'of', 'ids', 'to', 'mark', 'checked']
+ * - An array in the form [true, true, false, true, false] etc, where each item relates to the check status of
+ * the checkbox at the same index
+ * - An object containing ids of the checkboxes as keys and check values as properties
+ *
+ * @param {String} value The value to set the field to if the first argument was a string
+ */
+ onSetValue: function(id, value){
+ if(arguments.length == 1){
+ if(Ext.isArray(id)){
+ Ext.each(id, function(val, idx){
+ if (Ext.isObject(val) && val.setValue){ // array of checkbox components to be checked
+ val.setValue(true);
+ if (this.resetOriginal === true) {
+ val.originalValue = val.getValue();
+ }
+ } else { // an array of boolean values
var item = this.items.itemAt(idx);
if(item){
item.setValue(val);
}
- }, this);
- }else if(Ext.isObject(id)){
- //set of name/value pairs
- for(var i in id){
- var f = this.getBox(i);
- if(f){
- f.setValue(id[i]);
- }
}
- }else{
- this.setValueForItem(id);
+ }, this);
+ }else if(Ext.isObject(id)){
+ // set of name/value pairs
+ for(var i in id){
+ var f = this.getBox(i);
+ if(f){
+ f.setValue(id[i]);
+ }
}
}else{
- var f = this.getBox(id);
- if(f){
- f.setValue(value);
- }
+ this.setValueForItem(id);
}
}else{
- this.values = arguments;
+ var f = this.getBox(id);
+ if(f){
+ f.setValue(value);
+ }
}
- return this;
},
-
+
// private
- onDestroy: function(){
+ beforeDestroy: function(){
Ext.destroy(this.panel);
- Ext.form.CheckboxGroup.superclass.onDestroy.call(this);
+ if (!this.rendered) {
+ Ext.destroy(this.items);
+ }
+ Ext.form.CheckboxGroup.superclass.beforeDestroy.call(this);
},
-
+
setValueForItem : function(val){
val = String(val).split(',');
this.eachItem(function(item){
@@ -355,7 +443,7 @@ myCheckboxGroup.setValue('cb-col-1,cb-col-3');
}
});
},
-
+
// private
getBox : function(id){
var box = null;
@@ -367,8 +455,8 @@ myCheckboxGroup.setValue('cb-col-1,cb-col-3');
});
return box;
},
-
- /**
+
+ /**
* Gets an array of the selected {@link Ext.form.Checkbox} in the group.
* @return {Array} An array of the selected checkboxes.
*/
@@ -381,43 +469,39 @@ myCheckboxGroup.setValue('cb-col-1,cb-col-3');
});
return out;
},
-
- // private
- eachItem: function(fn){
+
+ /**
+ * @private
+ * Convenience function which passes the given function to every item in the composite
+ * @param {Function} fn The function to call
+ * @param {Object} scope Optional scope object
+ */
+ eachItem: function(fn, scope) {
if(this.items && this.items.each){
- this.items.each(fn, this);
+ this.items.each(fn, scope || this);
}
},
-
+
/**
* @cfg {String} name
* @hide
*/
- /**
- * @method initValue
- * @hide
- */
- initValue : Ext.emptyFn,
- /**
- * @method getValue
- * @hide
- */
- getValue : Ext.emptyFn,
+
/**
* @method getRawValue
* @hide
*/
getRawValue : Ext.emptyFn,
-
+
/**
* @method setRawValue
* @hide
*/
setRawValue : Ext.emptyFn
-
+
});
Ext.reg('checkboxgroup', Ext.form.CheckboxGroup);
-
-
+
+
\ No newline at end of file