Page 10 of 19 FirstFirst ... 89101112 ... LastLast
Results 91 to 100 of 188

Thread: XCheckbox - A nicer checkbox always submitting configurable values

  1. #91
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Vote Rating
    404
      0  

    Default

    Would you please check this? It's basically your logic - I just want to have it all in one place...
    PHP Code:
    // vim: ts=4:sw=4:nu:fdc=2:nospell
    /**
     * Ext.ux.form.XCheckbox - checkbox with configurable submit values
     *
     * @author  Ing. Jozef Sakalos
     * @version $Id: Ext.ux.form.XCheckbox.js 309 2008-08-13 10:38:55Z jozo $
     * @date    10. February 2008
     *
     *
     * @license Ext.ux.form.XCheckbox is licensed under the terms of
     * the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
     * that the code/component(s) do NOT become part of another Open Source or Commercially
     * licensed development library or toolkit without explicit permission.
     * 
     * License details: http://www.gnu.org/licenses/lgpl.html
     */

    /*global Ext */

    /**
      * @class Ext.ux.XCheckbox
      * @extends Ext.form.Checkbox
      */
    Ext.ns('Ext.ux.form');
    Ext.ux.form.XCheckbox Ext.extend(Ext.form.Checkbox, {
         
    submitOffValue:'false'
        
    ,submitOnValue:'true'

        
    ,onRender:function() {

            
    this.inputValue this.submitOnValue;

            
    // call parent
            
    Ext.ux.form.XCheckbox.superclass.onRender.apply(thisarguments);

            
    // create hidden field that is submitted if checkbox is not checked
            
    this.hiddenField this.wrap.insertFirst({tag:'input'type:'hidden'});

            
    // support tooltip
            
    if(this.tooltip) {
                
    this.imageEl.set({qtip:this.tooltip});
            }

            
    // update value of hidden field
            
    this.updateHidden();

        } 
    // eo function onRender

        /**
         * Calls parent and updates hiddenField
         * @private
         */
        
    ,setValue:function(v) {
            
    this.updateHidden(v);
            
    Ext.ux.form.XCheckbox.superclass.setValue.apply(thisarguments);
        } 
    // eo function setValue

        /**
         * Updates hiddenField
         * @private
         */
        
    ,updateHidden:function(v) {
            
    undefined !== this.checked;
            
    = (=== true || === 'true' || === '1' || String(v).toLowerCase() == 'on');
            if(
    this.hiddenField) {
                
    this.hiddenField.dom.value this.submitOnValue this.submitOffValue;
                
    this.hiddenField.dom.name '' this.el.dom.name;
            }
        } 
    // eo function updateHidden

    }); // eo extend

    // register xtype
    Ext.reg('xcheckbox'Ext.ux.form.XCheckbox);

    // eo file 
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  2. #92
    Ext User pbuyle's Avatar
    Join Date
    Mar 2008
    Location
    Belgium
    Posts
    32
    Vote Rating
    0
      0  

    Default

    Works for me.

    Thanks

  3. #93
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Vote Rating
    404
      0  

    Default

    Thank you for checking - I'm updating the first post.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  4. #94
    Ext User
    Join Date
    Jan 2008
    Posts
    76
    Vote Rating
    0
      0  

    Default

    sorry for bugging you guys!

    i still have a problem when i set my submitOffValue/submitOnValue...
    submit OK, but i cant load it with form.load

    Object:
    Code:
            fieldLabel: 'Desloc',
    	name: 'DESLOCAMENTO',
    	submitOffValue:'N',
        	submitOnValue:'S',
    	xtype: 'xcheckbox'
    JSON (DESLOCAMENTO = "1" Load perfect):
    Code:
    {"success":true,"data":{"RECOMENDACOES":"","FUNCIONARIO":"10","URGENCIA":"5","SITUACAO":"0","CLIENTEID"
    :"1426","DATATERMINO":"0000-00-00 00:00:00","TECNICO":"","DESLOCAMENTO":"1","PRAZO":"2008-08-18 16:09
    :41","SOLUCOES":"","IDGRUPO":"4458","DATAENTRADA":"2008-08-18 11:09:41","DATACC":"","DESCPROB":"teste","NOS":"4693","NOMECL":"MBC Materais para construcao","DATASAIDA":"0000-00-00 00:00:00"}}
    JSON (DESLOCAMENTO = "S" didnt Load):
    Code:
    {"success":true,"data":{"RECOMENDACOES":"","FUNCIONARIO":"10","URGENCIA":"5","SITUACAO":"0","CLIENTEID"
    :"1426","DATATERMINO":"0000-00-00 00:00:00","TECNICO":"","DESLOCAMENTO":"S","PRAZO":"2008-08-18 16:09
    :41","SOLUCOES":"","IDGRUPO":"4458","DATAENTRADA":"2008-08-18 11:09:41","DATACC":"","DESCPROB":"teste","NOS":"4693","NOMECL":"MBC Materais para construcao","DATASAIDA":"0000-00-00 00:00:00"}}
    So the form is submiting "S" when checked, but doesnt load checked with "S", just when "1"...

    Help!
    Thanks

    Ext 2.2
    Ext.ux.form.XCheckbox.js 82 2008-03-21 00:17:40Z jozo $

  5. #95
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Vote Rating
    404
      0  

    Default

    Try this code and let me please know if it works:
    PHP Code:
    // vim: ts=4:sw=4:nu:fdc=2:nospell
    /**
     * Ext.ux.form.XCheckbox - checkbox with configurable submit values
     *
     * @author  Ing. Jozef Sakalos
     * @version $Id: Ext.ux.form.XCheckbox.js 441 2009-01-12 11:10:10Z jozo $
     * @date    10. February 2008
     *
     *
     * @license Ext.ux.form.XCheckbox is licensed under the terms of
     * the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
     * that the code/component(s) do NOT become part of another Open Source or Commercially
     * licensed development library or toolkit without explicit permission.
     * 
     * License details: http://www.gnu.org/licenses/lgpl.html
     */

    /*global Ext */

    /**
      * @class Ext.ux.XCheckbox
      * @extends Ext.form.Checkbox
      */
    Ext.ns('Ext.ux.form');
    Ext.ux.form.XCheckbox Ext.extend(Ext.form.Checkbox, {
         
    submitOffValue:'false'
        
    ,submitOnValue:'true'

        
    ,onRender:function() {

            
    this.inputValue this.submitOnValue;

            
    // call parent
            
    Ext.ux.form.XCheckbox.superclass.onRender.apply(thisarguments);

            
    // create hidden field that is submitted if checkbox is not checked
            
    this.hiddenField this.wrap.insertFirst({tag:'input'type:'hidden'});

            
    // support tooltip
            
    if(this.tooltip) {
                
    this.imageEl.set({qtip:this.tooltip});
            }

            
    // update value of hidden field
            
    this.updateHidden();

        } 
    // eo function onRender

        /**
         * Calls parent and updates hiddenField
         * @private
         */
        
    ,setValue:function(v) {
            
    this.convertValue(v);
            
    this.updateHidden(v);
            
    Ext.ux.form.XCheckbox.superclass.setValue.apply(thisarguments);
        } 
    // eo function setValue

        /**
         * Updates hiddenField
         * @private
         */
        
    ,updateHidden:function(v) {
            
    undefined !== this.checked;
            
    this.convertValue(v);
            if(
    this.hiddenField) {
                
    this.hiddenField.dom.value this.submitOnValue this.submitOffValue;
                
    this.hiddenField.dom.name '' this.el.dom.name;
            }
        } 
    // eo function updateHidden

        /**
         * Converts value to boolean
         * @private
         */
        
    ,convertValue:function(v) {
            return (
    === true || === 'true' || == || === this.submitOnValue || String(v).toLowerCase() === 'on');
        } 
    // eo function convertValue

    }); // eo extend

    // register xtype
    Ext.reg('xcheckbox'Ext.ux.form.XCheckbox);

    // eof 
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  6. #96
    Ext User
    Join Date
    Jan 2008
    Posts
    76
    Vote Rating
    0
      0  

    Default

    Thanks! it Works!

  7. #97
    Ext User
    Join Date
    Dec 2007
    Posts
    95
    Vote Rating
    -1
      0  

    Default

    This extension is great, I was about to write basically the same thing and I'm glad I thought to search first. Thanks for sharing it!

  8. #98
    Sencha User radustefan's Avatar
    Join Date
    May 2008
    Posts
    43
    Vote Rating
    0
      0  

    Default

    Thank you Saki for this extension. I wonder why this code (and other) is not included as the standard checkbox control in the extjs distribution.

  9. #99
    Ext User
    Join Date
    Nov 2007
    Posts
    47
    Vote Rating
    0
      0  

    Default Mine is broken...

    PHP Code:
    {
                        
    xtype'panel',
                        
    title'Evaluacion del Fasciculo',
                        
    collapsibletrue,
                        
    autoHeighttrue,
                        
    autoWithtrue,                    
                        
    iconCls'evaluacion',
                        
    id:'evaluacionFasciculo',
                        
    defaults: {
                            
    width500
                        
    },
                        
    items: [                        
                                new 
    Ext.ux.form.XCheckbox({
                                    
    boxLabel'¿El artículo se identifica con membrete bibliográfico en la página inicial?',
                                    
    id'inicialCheckBox'
                                 
    }),
                                 new 
    Ext.ux.form.XCheckbox({
                                    
    boxLabel'¿El artículo se identifica con membrete bibliográfico  en las páginas interiores?',
                                    
    id'interiorCheckBox'
                                 
    })                                        
                        ] 
    /*del items del xtype*/                   
                        

    See image.
    Attached Images Attached Images

  10. #100
    Sencha User radustefan's Avatar
    Join Date
    May 2008
    Posts
    43
    Vote Rating
    0
      0  

    Default

    Have you included the css styles for xcheckbox?

Page 10 of 19 FirstFirst ... 89101112 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •