View Full Version : EditableGrid use date editor for certain rows, not the whole column

Syed Huda
15 Dec 2010, 10:18 AM
Is there any way to apply an editor for only certain rows and not the whole column?

I'm following this example:

And I want to use the following editor it mentions, only for the first row, NOT the whole column:

editor: new fm.DateField({
format: 'm/d/y',
minValue: '01/01/06',
disabledDays: [0, 6],
disabledDaysText: 'Plants are not available on the weekends'

How can I do that???

15 Dec 2010, 10:38 AM
Use the EditorGridPanel's beforeedit (http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.EditorGridPanel&member=beforeedit) event.

Syed Huda
15 Dec 2010, 11:05 AM
Fay, do you have an example of how beforeedit is used by any chance?

15 Dec 2010, 11:47 AM
Something like:

var grid = new Ext.grid.EditorGridPanel({
listeners: {
beforeedit: function(e)
if (e.rowIndex != 0)
e.cancel = true; // or return false from beforeedit.

See also: http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.ColumnModel&member=iscelleditable

Syed Huda
15 Dec 2010, 12:24 PM
I tried using beforeedit to format the column as datefield when the user clicks on the first row:

listeners : {
beforeedit : function(e) {
if (e.row == 0){
e.grid.getColumnModel().setEditor(e.column, gridDateField);
} else {
e.grid.getColumnModel().setEditor(e.column, gridTextField);

This almost works, basically it formats the first field as a date.
Then on the second row, field one it is treated as text and that works fine, but then i click the next row down (row 3) same column and it doesn't allow me to edit and fires this error in firebug:

this.field.getEl().dom is undefined
chrome://firebug/content/blank.gifExt.DomHelper=function(){var s=null,j=...emoting=Ext.direct.RemotingProvider;