Sha256: 8ce11fce7ab90daeba7c7b84e65f0de96bd35ee20795097d4dfd6a87a0ac0d88

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

Ext.ns("Ext.netzke.form");

/*
A very simple CheckboxGroup extension, which serializes its checkboxes' "boxLabel" attributes into a string.
Config options:
* separator - separator of values in the string (defaults to ",")
* options - all checkboxes, by boxLabel, e.g.: ["Cool", "To read", "Important"]
*/
Ext.define('Ext.netzke.form.CommaListCbg', {
  extend: 'Ext.form.CheckboxGroup',
  alias: 'widget.commalistcbg',
  separator: ",",

  initComponent: function(){
    this.items = [];
    Ext.each(this.options, function(o){
      this.items.push({ boxLabel: o, displayOnly:true });
    }, this);

    this.callParent();
  },

  getSubmitData: function(){
    var res = [];
    Ext.each(this.getChecked(), function( item ){ res.push( item.boxLabel ) });
    res = res.join(this.separator);
    var o = {};
    o[this.name]=res;
    return o;
  },

  setValue: function(v){
    if (Ext.isString(v)) {
      var passedValues = v.split(this.separator);
      this.items.each(function(i){
        i.setValue( passedValues.indexOf(i.boxLabel) >= 0 );
      });
    // we can alse set values the Ext way
    } else {
      this.callParent(arguments);
    }
  },

  setReadonlyMode: function(onOff) {
    this.items.each(function(i){
      i.setReadonlyMode(onOff);
    });
  }

});

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
netzke-basepack-0.7.7 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-zh-0.7.6 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-0.7.6 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-0.7.5 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-0.7.4 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-0.7.3 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-0.7.2 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-0.7.1 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
netzke-basepack-0.7.0 lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js