PDA

View Full Version : [SOLVED] Grid-Error when double-clicking a row - this.getRow(row) undefined



PranKe01
20 Jan 2010, 11:48 AM
I found a bug, but I don't know if I find some time to create a testcase.
I'll describe - maybe it's enough to reproduce the bug.

Ext version tested:
Ext 3.1

Adapter used:
ext
air

css used:
ext-all.css
ext-air.css
statusbar.css

Browser versions tested against:
Adobe Air

Operating System:
WinXP Pro & Windows 7 Ultimate

Description:

I got a TabPanel in which I create a html-Item with a div-container. Then I render a grid into this div-container. When double click on a row, a new Tab will be created and gets active. In this Tab is another TabPanel, with some grids and a form in it.
When I close this created Tab and double-click on another row in the Grid which is rendered to the div-container, I get an error:


TypeError: Result of expression 'this.getRow(row)' [undefined] is not an object.

at app:/lib/ext/ext-all-debug.js : 41154

at app:/lib/ext/ext-all-debug.js : 41667

at app:/lib/ext/ext-all-debug.js : 41685

at app:/lib/ext/ext-all-debug.js : 41639

at app:/lib/ext/ext-all-debug.js : 41634

at app:/lib/ext/ext-all-debug.js : 43410

at app:/lib/ext/ext-all-debug.js : 1577

at app:/lib/ext/ext-all-debug.js : 1324

at app:/lib/ext/ext-all-debug.js : 40707

at app:/lib/ext/ext-all-debug.js : 40730

h at app:/lib/ext/ext-all-debug.js : 1934

undefined at undefined : undefined

This error appears twice. When I click the first time and when I click the second time (because its a double-click).

If this Information doesn't help to find the Bug, I'll try to create a testcase...

Jamie Avins
20 Jan 2010, 12:05 PM
Really need a test case...

PranKe01
21 Jan 2010, 6:41 AM
After some try'n'error I found the problem in my source. It's still a bug, I think, but it would take too long for me to create a testcase...

Anyway, I try to describe the problem:
I got a Grid in which Items are displayed. When I dblclick on an Item, a new Tab is created, in which another TabPanel with three tabs is created. On the first tab a form is created, on the second a groupinggrid and on the third are 3 grids.
Here is the code, with which I created the first of the three grids:

this.createNachrichtenGrid = function(aktenid, data){
if(Ext.get('nachrichtengrid'+aktenid) != null){
var ds = new Ext.ux.data.PagingJsonStore({
autoLoad: true,
autoDestroy: true,
autoSave: false,
lastOptions: {
params:{start: 0, limit: 5}
},
data: data,
root: 'Nachricht',
idProperty: 'ID',
fields: c_StoreManager.nachrichtenFields,
sortInfo: {
field: 'ID',
direction: 'DESC'
}
});

var grid = new Ext.grid.GridPanel({
el: 'nachrichtengrid'+aktenid,
id: 'gridNachrichten'+aktenid,
ds: ds,
cm: c_StoreManager.nachrichtenColModel,
sm: c_StoreManager.selModel,
autoWidth: true,
monitorResize: true,
title:'Nachrichten',
autoHeight: true,
columnLines: true,
view: new Ext.grid.GridView({
emptyText: 'Keine Nachrichten vorhanden!',
deferEmptyText: false,
forceFit: true,
scrollOffset: 1,
getRowClass : function(row, index){
if(!row.data.Gelesen){
return 'yellow-row'
}
return '';
}
}),
bbar: new Ext.PagingToolbar({
pageSize: 5,
store: ds,
displayInfo: true,
displayMsg: 'Nachrichten {0} - {1} von {2}',
emptyMsg: "Keine Nachrichten vorhanden!",
autoWidth: true,
listeners: {
afterrender: function(comp){
comp.refresh.hide();
grid.getBottomToolbar().doLoad(0);
}
},
buttons: {
text: 'Neue Nachricht verfassen',
hidden: !isEditableAkte(aktenid),
handler: function(){
c_InterfaceManager.showNachricht(0, false, aktenid);
}
}
})
});

grid.on('rowdblclick', c_InterfaceHandlingManager.nachrichtenGridDblClickRow, this);
grid.on('rowcontextmenu', c_InterfaceHandlingManager.nachrichtenGridRightClickRow, this);
Ext.get('nachrichtengrid'+aktenid).dom.innerHTML = '';
grid.render();
}
};

In the c_StoreManager is the selectionModel for this grid:

this.selModel = new Ext.grid.RowSelectionModel({
singleSelect:true
});

And here comes the workaround:
I just copied the selectionModel out of the StoreManager and copied it to the function above! Now the code looks like this and everything works fine:

this.createNachrichtenGrid = function(aktenid, data){
if(Ext.get('nachrichtengrid'+aktenid) != null){
var ds = new Ext.ux.data.PagingJsonStore({
autoLoad: true,
autoDestroy: true,
autoSave: false,
lastOptions: {
params:{start: 0, limit: 5}
},
data: data,
root: 'Nachricht',
idProperty: 'ID',
fields: c_StoreManager.nachrichtenFields,
sortInfo: {
field: 'ID',
direction: 'DESC'
}
});

var selModel = new Ext.grid.RowSelectionModel({
singleSelect:true
});

var grid = new Ext.grid.GridPanel({
el: 'nachrichtengrid'+aktenid,
id: 'gridNachrichten'+aktenid,
ds: ds,
cm: c_StoreManager.nachrichtenColModel,
sm: selModel,
autoWidth: true,
monitorResize: true,
title:'Nachrichten',
autoHeight: true,
columnLines: true,
view: new Ext.grid.GridView({
emptyText: 'Keine Nachrichten vorhanden!',
deferEmptyText: false,
forceFit: true,
scrollOffset: 1,
getRowClass : function(row, index){
if(!row.data.Gelesen){
return 'yellow-row'
}
return '';
}
}),
bbar: new Ext.PagingToolbar({
pageSize: 5,
store: ds,
displayInfo: true,
displayMsg: 'Nachrichten {0} - {1} von {2}',
emptyMsg: "Keine Nachrichten vorhanden!",
autoWidth: true,
listeners: {
afterrender: function(comp){
comp.refresh.hide();
grid.getBottomToolbar().doLoad(0);
}
},
buttons: {
text: 'Neue Nachricht verfassen',
hidden: !isEditableAkte(aktenid),
handler: function(){
c_InterfaceManager.showNachricht(0, false, aktenid);
}
}
})
});

grid.on('rowdblclick', c_InterfaceHandlingManager.nachrichtenGridDblClickRow, this);
grid.on('rowcontextmenu', c_InterfaceHandlingManager.nachrichtenGridRightClickRow, this);
Ext.get('nachrichtengrid'+aktenid).dom.innerHTML = '';
grid.render();
}
};

I don't know what exactly the problem is - maybe you guys got :)

Condor
21 Jan 2010, 7:00 AM
1. Are you only using c_StoreManager.nachrichtenColModel and c_StoreManager.selModel for this single grid? You can't share column and selection models between grids!
2. Do you ever destroy and later recreate this grid? In that case you also need to recreate the column and selection model!

PranKe01
21 Jan 2010, 7:55 AM
Oh - I didn't know, that I cannot share a SelectionModel :-? Maybe this should be noticed anywhere (if it is not already and I didn't read it).
I don't call a function to destroy the grid, but when the tab is closed, the grid gets destroyed - or not?!
I used the singleSelect in more than one grid - I changed it now. I think this is the problem!