API Docs for:
Show:

Y.DataTable.EditorOptions.checkbox Class

Popup Cell Editor "checkbox"

This View configuration is used to setup a simple checkbox (i.e. on/off, yes/no, true/false) popup cell editor within the popup Overlay.

Basic Usage
   // Column definition
   { key:'arrived', editor:"checkbox",
     editorConfig:{ checkboxHash:{ 'true':'Y', 'false':'N' } }
   }
Standard Configuration

This editor creates a single INPUT[type=checkbox] element internally within the Overlay and directly positioned over the TD element. The checkbox is either "on" or "off", and the setting is mapped to the data value via the checkboxHash editorOption ....

The configuration {Object} for this cell editor View is predefined as;

   Y.DataTable.EditorOptions.checkbox = {
       BaseViewClass:  Y.DataTable.BaseCellPopupEditor,
       name:           'checkbox',

       templateObject: {
          html: '<input type="checkbox" title="inline cell editor" />'
       },

       // Define listeners to this View instance ...
       after : {

           //---------
           // After this cell editor instance is created,
           //   setup a click listener on the INPUT[checkbox]
           //---------
           editorCreated: function(){
               var cbox = this.overlay.get('contentBox');

               this._subscr.push(
                   cbox.delegate('click',function(e){
                       var chk    = e.currentTarget,
                           cvalue = chk.get('checked') || false,
                           chkopt = this.get('checkboxHash') || { 'true':true, 'false':false },
                           val    = chkopt[cvalue];

                       if(this._isZeroOr(val)) {
                           this.saveEditor(val);
                       }


                   },'input[type="checkbox"]', this)
               );
           },

           //---------
           // After this editor is displayed,
           //   update the "checked" status based on the underlying o.value
           //---------
           editorShow : function(o){
               var chk    = this.overlay.get('contentBox').one('input[type="checkbox"]'),
                   val    = o.value || this.get('value'),
                   chkopt = (this.get('checkboxHash')) ? this.get('checkboxHash') : { 'true':true, 'false':false },
                   chkst  = false;

               if(chk && val !== undefined ) {
                   chkst = (val === chkopt.true ) ? true : false;
                   chkst = (val === chkopt.false ) ? false : chkst;
                   chk.set('checked',chkst);
               }
           }
       }
   };

PLEASE NOTE: All other attributes from the BaseViewClass apply and can be included within the editorConfig object.

Item Index