需求:想在EditorGridPanel的不同行的同一列顯示不同的編輯器
代碼:
方法一:
this.grid.on("cellclick",function(grid,rowIndex,colIndex,e){
var innerName = grid.store.getAt(rowIndex).data.innerName;
var column = grid.getColumnModel().columns[colIndex];
if(innerName=="startTime"){
this.startTime = new Ext.form.DateField({
format:'Y-m-d',
name:'startTime',
readOnly:false,
minValue:new Date()
});
column.setEditor(this.startTime);
}
if(innerName=="home"){
this.home = new Ext.form.TextField({
省略
});
column.setEditor(this.home);
}
});
方法二:
this.grid.getColumnModel().getCellEditor=function(colIndex,rowIndex){
var innerName = Ext.getCmp("grid").getStore().getAt(rowIndex).data.innerName;
if(innerName=="startTime"){
this.startTime = new Ext.form.DateField({
format:'Y-m-d',
name:'startTime',
readOnly:false,
minValue:new Date()
});
return new Ext.grid.GridEditor(this.startTime);
}
return Ext.grid.ColumnModel.prototype.getCellEditor.call(this,colIndex,rowIndex);
};