1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Vote Rating
    1
    adinan is on a distinguished road

      0  

    Default Answered: How to make checkcolumn read string values instead of boolean

    Answered: How to make checkcolumn read string values instead of boolean


    Greetings,

    I have a grid, and one of its columns is a checkcolumn (Ext.ux.CheckColumn, from the cell editing example).
    By default the checkcolumn reads a column with boolean values, but my column returns from the server 'Y' and 'N' values.

    I would like to make the checkcolumn understand these two values, instead of true and false. Is there a way to do it or should I make the server return true or false instead?

    Thanks in advance.

  2. Personally I would return boolean. If you want to stick with Y/N then you can change the renderer. Currently it is like this:

    Code:
        renderer : function(value){
            var cssPrefix = Ext.baseCSSPrefix,
                cls = [cssPrefix + 'grid-checkheader'];
    
            if (value) {
                cls.push(cssPrefix + 'grid-checkheader-checked');
            }
            return '<div class="' + cls.join(' ') + '">&#160;</div>';
        }
    You can simple change it to:

    Code:
        renderer : function(value){
            var cssPrefix = Ext.baseCSSPrefix,
                cls = [cssPrefix + 'grid-checkheader'];
    
            if (value === 'Y') {
                cls.push(cssPrefix + 'grid-checkheader-checked');
            }
            return '<div class="' + cls.join(' ') + '">&#160;</div>';
        }
    Be aware, if you have a sync request, it will probably send boolean back to your server.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    Personally I would return boolean. If you want to stick with Y/N then you can change the renderer. Currently it is like this:

    Code:
        renderer : function(value){
            var cssPrefix = Ext.baseCSSPrefix,
                cls = [cssPrefix + 'grid-checkheader'];
    
            if (value) {
                cls.push(cssPrefix + 'grid-checkheader-checked');
            }
            return '<div class="' + cls.join(' ') + '">&#160;</div>';
        }
    You can simple change it to:

    Code:
        renderer : function(value){
            var cssPrefix = Ext.baseCSSPrefix,
                cls = [cssPrefix + 'grid-checkheader'];
    
            if (value === 'Y') {
                cls.push(cssPrefix + 'grid-checkheader-checked');
            }
            return '<div class="' + cls.join(' ') + '">&#160;</div>';
        }
    Be aware, if you have a sync request, it will probably send boolean back to your server.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1