the problem is, after destroy the window the editor is gone. I have the following two solutions
PHP Code:
Ext.kv73.FeedbackGrid = Ext.extend(Ext.grid.GridPanel, {
//some properties
,initComponent:function() {
Ext.apply(this, {
editor : new Ext.ux.grid.RowEditor({
saveText: 'Speichern'
,cancelText: 'Abbrechen'
,listeners:{
beforeedit : function(editorPanel,rowIndex){
var rec = editorPanel.grid.getStore().getAt(rowIndex);
if (rec.data.user != currentUserName) {
return false;
}
return true;
}
}
})
});
Ext.apply(this, {
store: //store
,listeners: //listeners
})
,columns: [{
header: "Kopf", id:'headline', width: 250, sortable: true, dataIndex: 'headline', editor: {
xtype: 'textarea'
,allowBlank: false
}, renderer: this.renderPreTag
}]
,plugins: [
this.editor
]
});
Ext.kv73.FeedbackGrid.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
,onRender: function() {
this.store.load();
Ext.kv73.FeedbackGrid.superclass.onRender.apply(this, arguments);
} // eo function onRender
,listeners: {
headerclick: function(grid, columnIndex, eventObject) {
var header = grid.colModel.getColumnHeader(columnIndex);
var out = header.match('div');
if ( out != null) {
var record = new this.feedback({
headline: 'Kopfzeile'
,content: 'Text'
,user: currentUserName
,lastUpdated: new Date()
,dateCreated: new Date()
});
this.editor.stopEditing();
this.store.insert(0, record);
this.getView().refresh();
this.getSelectionModel().selectRow(0);
this.editor.startEditing(0);
}
}
,feedback: Ext.data.Record.create([{
name: 'headline',
type: 'string'
}, {
name: 'content',
type: 'string'
}, {
name: 'user',
type: 'string'
},{
name: 'lastUpdated',
type: 'date'
,dateFormat: 'n/j/Y'
},{
name: 'dateCreated',
type: 'date'
,dateFormat: 'n/j/Y'
}])
});
Ext.reg('feedbackgrid', Ext.kv73.FeedbackGrid);
a other way to inizialise the plugin could be
PHP Code:
,plugins: [
new Ext.ux.grid.RowEditor({
saveText: 'Speichern'
,cancelText: 'Abbrechen'
,listeners:{
beforeedit : function(editorPanel,rowIndex){
var rec = editorPanel.grid.getStore().getAt(rowIndex);
if (rec.data.user != currentUserName) {
return false;
}
return true;
}
}
})
]
and in the headerclick listener
PHP Code:
this.plugins[0].stopEditing();
this.store.insert(0, record);
this.getView().refresh();
this.getSelectionModel().selectRow(0);
this.plugins[0].startEditing(0);
in the first solution i have 2 times Ext.apply and in the second i have to write this.plugins[0]... So, what is the best way to implement (initialize ) the plugin?
thanks for help