PDA

View Full Version : Getting strange error this.grid is undefined ext-all-debug.js (line 47393)



gamodg
30 Oct 2011, 10:28 AM
Hi

I have an editor grid



Grid.Selection = Ext.extend(Ext.grid.EditorGridPanel, {
layout:'fit',
border:false,
stateful:false,

initComponent: function() {

Ext.apply(this, {
// {{{
store: new Ext.data.SimpleStore({
id: 0,
fields: [ ...],
data: []
})
,cm: new Ext.grid.ColumnModel({
// specify any defaults for each column
defaults: {
sortable: true // columns are not sortable by default
},
columns: [
rowNumberer,
combo1,
combo2,
combo3,
itemDeleter]
})
// }}}
,plugins: new Ext.ux.plugins.GridValidator()
,viewConfig: {forceFit: true}
,sm: itemDeleter
,height: 150
,frame: true
,clicksToEdit: 1
,tbar: [{
text: 'Add New Association'
,id: 'addBtnGrid'
,iconCls: 'icon-plus'
,listeners: {
click: {scope: this,fn: this.addRecord,buffer: 200}
}
}]
}); // eo apply


// call parent
Grid.Selection.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
// }}}
// {{{
,onRender: function() {
// call parent
Grid.Selection.superclass.onRender.apply(this, arguments);
} // eo function onRender
// }}}
// {{{
,addRecord: function() {
record = this.store.recordType;
rec = new record({
...
});
this.stopEditing();
this.store.insert(0, rec);
this.getView().refresh(); // GETTING ERROR ON THIS LINE
this.getSelectionModel().selectRow(0);
this.startEditing(0, 0);
} // eo function addRecord

,reset: function() {
this.store.removeAll();
this.addRecord();
}
}); // eo extend


// register xtype
Ext.reg('selectionGrid', Grid.Selection);


I add this grid to a form.
When I display the form I reset the grid which removes all records from the store and add a single new record.
But when this.getView().refresh(); is called I get
this.grid is undefined
this.grid.stopEditing(true); ext-all-debug.js (line 47393)

The item deleter plugin [http://code.google.com/p/extensive/source/browse/trunk/extensive/js/grid/ItemDeleter.js?r=13] is also calling
grid.getView().refresh() but it works.

I will be highly grateful if somebody can guide me.