PDA

View Full Version : Combobox "losts" the Store...



g2mac
18 Jul 2009, 11:23 AM
Hi,
i'm working with Combobox with mode 'remote' in Grid with RowEditor plugin. Grid is in Window. When I first time open window all is ok. But after I close window and try to open it again I get an error message in Firebug:
this.store is null
chrome://firebug/content/blank.gif if(this.store.getCount() > 0){\n (ext-all-debug.js (Zeile 32918))

Why? Thank's for your help!
Here is my code:



Ext.util.Format.comboRenderer = function(combo){
return function(value){
var record = combo.findRecord(combo.valueField, value);
return record ? record.get(combo.displayField) : combo.valueNotFoundText;
}
}

var Combo = new Ext.form.ComboBox({
editable: false,
//typeAhead: true,
triggerAction: 'all',
lazyRender:true,
listClass: 'x-combo-list-small',
displayField: 'item',
valueField: 'id',
store: new Ext.data.ArrayStore({
autoLoad: true,
restful: true,
idIndex: 0,
fields: ['id','item'],
url: '/fm/combo/599',
listeners: {
load: function(store,rs) {
alert("Loaded: "+rs.length);
}
}
}
});

.... I use Web Desktop sample...
createWindow : function(src){
var desktop = this.app.getDesktop();
var win = desktop.getWindow('bogus'+src.tableId);
if(!win){
alert(Combo.store.getCount()); // gets 3 - store is Ok!
var gridCfg = {
id: 'table'+src.tableId,
store: new Ext.data.Store({
storeId: 'store'+src.tableId,
autoLoad: true,
restful: true,
proxy: new Ext.data.HttpProxy({
url: '/fm/tables/'+src.tableId,
restful: true
}),
reader: new Ext.data.JsonReader({root:'data'}),
writer: new Ext.data.JsonWriter()
}),
cm: new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: src.cm
/* part of src.cm:
...
header: 'Status',
dataIndex: 'status_id',
editor: Combo,
renderer: Ext.util.Format.comboRenderer(Combo)
....
*/
}),
view: new Ext.ux.BufferView({
rowHeight: 21,
scrollDelay: false,
markDirty: false
}),
iconCls: ''
};
win = desktop.createWindow({
id: 'bogus'+src.tableId,
title:src.text,
width:640,
height:200,
iconCls: 'bogus',
shim:false,
animCollapse:false,
constrainHeader:true,
layout: 'fit',
items: new Ext.grid.GridPanel(gridCfg)
});
}
win.show();

momospeedracer
20 Jul 2009, 6:07 PM
I currently have the same problem as you.

I am using a combobox inside a grid inside a formpanel and when the formpanel is rendered first time, everything is okay. However, when the formpanel is closed (autoDestroy: true on formpanel) and a new formpanel is opened, I get the same error on that combobox.

Condor
21 Jul 2009, 12:52 AM
Destoying a window will destroy all component inside. You'll have to recreate all component when you create the window again.

(move the Combo creation inside the createWindow method)

g2mac
22 Jul 2009, 12:27 AM
Destoying a window will destroy all component inside. You'll have to recreate all component when you create the window again.


But why hasn't window destroyed Combo object? After recreation the window I get in my alert(Combo)==Object;

Condor
22 Jul 2009, 12:31 AM
'destroy' doesn't mean 'remove', it just mean 'cleanup'.

The Combo object still exists (because you hold a reference to it), but it is unusable and it will be removed by the garbage collector as soon as you release the reference to it (e.g. set Combo = null).

g2mac
22 Jul 2009, 1:10 AM
Oh, I didn't know that )) Thanks a lot!

momospeedracer
22 Jul 2009, 11:31 AM
'destroy' doesn't mean 'remove', it just mean 'cleanup'.

The Combo object still exists (because you hold a reference to it), but it is unusable and it will be removed by the garbage collector as soon as you release the reference to it (e.g. set Combo = null).

I scratched my head for about a day on that until it clicked.

Ultimately, I ended up re-assigning the store to the comboboxes and the issue was solved.