PDA

View Full Version : How to make checkcolumn read string values instead of boolean



adinan
10 Jan 2012, 5:41 AM
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.

mitchellsimoens
10 Jan 2012, 7:23 AM
Personally I would return boolean. If you want to stick with Y/N then you can change the renderer. Currently it is like this:


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:


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.