View Full Version : Want grid checkcolumn to display !value of dataIndex

7 Apr 2014, 1:50 PM
My model has a field 'notnull' which is server data and my grid's column is a checkcolumn with text of 'Allow Null'. I'm trying to get the column to render !value and can't figure out how. I tried a renderer but it removes checkbox completely.

7 Apr 2014, 10:32 PM
I use the following:

{ header: 'Inactive', dataIndex: 'bInactive',
editor: {
xtype: 'checkbox',
allowBlank: true,
cls: 'x-grid-checkheader-editor'
renderer: function(value) { // This function converts true and false into checkbox checked or unchecked
if (value == "0" || value == "false")
value = false;
else if(value == "1" || value == "true")
value = true;
return "<input type='checkbox' disabled='disabled'" + (value ? "checked='checked'" : "") + ">";

This allows it to be used in row editing or cell editing plugins also. In my case, the value could be a string and thats why I do the if-else. At the end, depending on the value, you can tell the checkbox to be checked or not...