View Full Version : How do I show/hide the editor in a grid cell

15 Jul 2009, 10:01 AM
Hi, I am new to Extjs and I am having trouble understanding how to customize the display of certain cells in a grid.

I have the following column model:

,cm: new Ext.grid.ColumnModel(
{other column definitions....}
,{header: 'Performance Factor', dataIndex: 'proposedpercent'
,renderer: this.formatInput
,align: 'right', width: 85, sortable: true
// I would like the editor to only show if the iseligible value for the record is 1
,editor: { xtype: 'numberfield' ,allowBlank: true}

Then I have the renderer definition as follows:

,formatInput: function(value, metaData, record, rowIndex, colIndex, store) {
var dvalue = value;
if(record.data.iseligible == 1) {
// if eligible then show the input box
metaData.attr = 'style="color: #15428B;border: 1px solid #D0D0D0; text-align: right; background: #eeeeee"';

} else {
// otherwise just show the text 'Not Eligible'
metaData.attr = 'style="color: gray; font-style: italic; text-align: center;"';
dvalue = 'Not Eligible';
return dvalue;

Can anyone please help me? I need to hide the input box when record.data.iseligible == 1

Thanks in advance