Results 1 to 7 of 7

Thread: Combobox "losts" the Store...

  1. #1
    Sencha User g2mac's Avatar
    Join Date
    Jun 2009
    Location
    Odessa, Ukraine
    Posts
    69

    Default Combobox "losts" the Store...

    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
    [IMG]chrome://firebug/content/blank.gif[/IMG] if(this.store.getCount() > 0){\n (ext-all-debug.js (Zeile 32918))

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

    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();

  2. #2

    Default Exact same issue encountered here.

    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.

  3. #3
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    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)

  4. #4
    Sencha User g2mac's Avatar
    Join Date
    Jun 2009
    Location
    Odessa, Ukraine
    Posts
    69

    Default

    Quote Originally Posted by Condor View Post
    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;

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    '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).

  6. #6
    Sencha User g2mac's Avatar
    Join Date
    Jun 2009
    Location
    Odessa, Ukraine
    Posts
    69

    Default

    Oh, I didn't know that )) Thanks a lot!

  7. #7

    Default

    Quote Originally Posted by Condor View Post
    '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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •