-
10 Jan 2012 5:41 AM #1
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.
-
Best Answer Posted by mitchellsimoens
Personally I would return boolean. If you want to stick with Y/N then you can change the renderer. Currently it is like this:
You can simple change it to: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(' ') + '"> </div>'; }
Be aware, if you have a sync request, it will probably send boolean back to your server.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(' ') + '"> </div>'; }
-
10 Jan 2012 7:23 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
Personally I would return boolean. If you want to stick with Y/N then you can change the renderer. Currently it is like this:
You can simple change it to: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(' ') + '"> </div>'; }
Be aware, if you have a sync request, it will probably send boolean back to your server.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(' ') + '"> </div>'; }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote