PDA

View Full Version : this.config is undefined for ColumnModel



Albinoswordfish
23 Dec 2010, 1:11 PM
Right now I have a GridPanel and BoxComponent inside of a Window Component. I'm getting this strange error when I first open the window there is no error. However if I close the window and open it up again Firefox throws this error:


Error: this.config is undefined
Source File: .../ext-3.3.1/ext-all-debug.js
Line: 49009

Here is the line it's talking about


getColumnCount : function(visibleOnly) {
-> var length = this.config.length,
c = 0,
i;
.....


This is in the ColumnModel code.

Here is my GridPanel code below:


Controls.TimelineWindowFlightList = Ext.extend(Ext.grid.GridPanel,{
id: 'timeline-flight'
,
title: 'Flight List'
,
columnWidth: .7
,
ddGroup:'tl'
,
ddText: null
,
store : new Ext.data.Store({
data: dummyData
,
reader: new Ext.data.ArrayReader({}, [
{name: 'Sorted Time'},
{name: 'ACID'},
{name: 'Major'},
{name: 'Status'}

])
})
,
enableDragDrop : true
,
colModel: new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: [
{header: 'Sorted Time', dataIndex: 'Sorted Time'},
{header: 'ACID', dataIndex: 'ACID'},
{header: 'Major', dataIndex: 'Major'},
{header: 'Status', dataIndex: 'Status'}
]
})
,
viewConfig: {
forceFit: true
}
,
selModel: new Ext.grid.RowSelectionModel({
singleSelect : true
,
listeners: {
beforerowselect: function(sm,i,ke,row){
this.grid.ddText = row.data.ACID;
}
}
})
,
constructor : function(config){
Ext.apply(this, config);
Controls.TimelineWindowFlightList.superclass.constructor.call(this, config);
}
});

Has anybody ever run into something like this before? I'm not really sure what this means.

firefoxSafari
23 Dec 2010, 5:36 PM
Could you post more code, especially where you are instantiating the grid?

I'm not sure, but using id: like you are in an Ext.extend is usually a red flag. The id on a component is supposed to be unique. If you did new Controls.TimelineWindowFlightList() twice, the results could be unpredictable. It's best to avoid hard-coding an id whenever possible.

Condor
24 Dec 2010, 1:13 AM
Also, do NOT put complex objects (store, colModel, viewConfig, selModel) in the prototype.

Add them to the config in the constructor (or initComponent).

Albinoswordfish
25 Dec 2010, 9:30 AM
@Condor,

Could you show me an example of how to do that?

tqwwilliam
12 Jan 2012, 9:08 AM
Hi, have u solved this problem ? I got the same one, can you show me how to solve it ?

Albinoswordfish
12 Jan 2012, 10:07 AM
I know this is old but thanks everyone for their help. I was able to solve this issue by following Condor's advice.
I moved all of my instance creation of complex objects into the constructor, also I removed the the 'id' tag in the prototype. My code now looks like this:


Controls.TimelineWindowFlightList = Ext.extend(Ext.grid.GridPanel,{
title: 'Flight List'
,
columnWidth: .7
,
ddGroup:'tl' //must be the same as the ddGroup defined in the DropTarget prototype
,
ddText: null
,
ddAirport: null
,
store: null
,
enableDragDrop : false
,
viewConfig: {
forceFit: true
}
,
loadMask : true
,
stripeRows: true
,
autoDestroy: false
,
prevMin: null //previous minute mark of system, used to see if system time has changed
,
constructor : function(config){
Ext.apply(this, config);

this.store = new Ext.data.Store(
{
data: dummyData,
reader: new Ext.data.ArrayReader({},[{name: "ACID"},{name: "ETA"}] )
});

this.cm = new Ext.grid.ColumnModel({
defaults:
{
sortable: true,
hidden: false
}
,
columns: [
{
id: 'acid', header: 'ACID', dataIndex: 'ACID'
}
,
{
header: 'ETA', dataIndex: 'ETA'
}
]
});

this.selModel = new Ext.grid.RowSelectionModel({
singleSelect : true
,
listeners: {
beforerowselect: function(sm,i,ke,row){
this.grid.ddText = row.data.ACID;
this.grid.ddAirport = row.data.ADES;
}
}
});

Controls.TimelineWindowFlightList.superclass.constructor.call(this, config);
}