Results 1 to 4 of 4

Thread: Grid inside closable window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    126

    Default Grid inside closable window

    Hey,

    I've put a grid inside a closable window. First time when I open the window, everything works. But when I close the window and then reopen it, the window appears, but the grid doesn't and the all the events of the window also stop functioning. What could be the problem?

    Here's my window and grid config :


    WINDOW:

    Code:
    var selectAddressee = function(label) {
            labelId = label;
            if (!addressPopup) {
                var addressPopup = new Ext.Window({
                    title : 'Select Patients',
                    width : 500,
                    resizable : false,
                    id : label + 'addressPopup',
                    name : label + 'addressPopup',
                    height : 400,
                    modal : true,
                    closeAction : 'hide',
                    closable : true,
                    items : [addressGrid],
                    buttons : [{
                        text : 'Add Selected',
                        handler : function() {
                            var selected = addressGrid.getSelectionModel()
                                    .getSelections();
                            if (selected) {
                                var emails = '';
                                Ext.each(selected, function(record) {
                                            emails = emails + record.data.emailId
                                                    + ';';
                                        });
                                console.log(emails);
                                var labelCmp = Ext.getCmp(label);
                                if (labelCmp) {
                                    labelCmp.reset();
                                    labelCmp.setValue(emails);
                                }
                                addressPopup.hide();
                            }
                        }
                    }, {
                        text : 'Cancel',
                        handler : function() {
                            addressPopup.hide();
                        }
                    }]
                });
            }
            addressPopup.show(label);
        }
    GRID:

    Code:
    var addressGrid = new Ext.grid.GridPanel({
            autoScroll : 'auto',
            columns : emailGridCol,
            frame : false,
            stripeRows : true,
            id : 'addressGrid',
            sm : checkbox,
            autoWidth : true,
            height : 325,
            trackMouseOver : true,
            store : addressGridStore,
            bbar : pagingToolbar,
            viewConfig : {
                forceFit : true,
                markDirty : false
            },
            listeners : {
                viewready : {
                    fn : function(grid) {
                        var selectedEmails = [];
                        var labelCmp = Ext.getCmp(labelId);
                        if (labelCmp) {
                            var emails = labelCmp.getValue().split(';');
                            if (emails) {
                                Ext.each(emails, function(email) {
                                            grid.getStore().each(function(record) {
                                                        if (record.data.emailId === email) {
                                                            selectedEmails.push(record);
                                                        }
                                                    })
                                        });
                            }
                        }
                        grid.getSelectionModel().selectRecords(selectedEmails);
                    }
                }
            }
        });

  2. #2
    Sencha User
    Join Date
    Dec 2010
    Posts
    126

    Default

    got it working..

  3. #3
    Sencha User
    Join Date
    May 2013
    Posts
    8

    Default

    Thanks for the awesome solution you posted.

  4. #4
    Sencha User
    Join Date
    Jan 2011
    Posts
    549

    Default

    If you're struggling with this problem, then the cause will be because when you close your window it is destroying everything within (grid, store, etc).

    The solution is either to change your window closeAction config to "hide", or to recreate your grid component everytime the window is opened.

Similar Threads

  1. is closable Ext.Window destroyed from dom on close?
    By andynuss in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 22 Oct 2009, 3:48 AM
  2. Window + closable
    By wlee in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 20 Nov 2008, 8:59 AM
  3. Window that is closable but without title bar
    By jbaldwin in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 4 Nov 2008, 12:09 AM
  4. [2.2] Disabled window closable using esc key in FF3
    By The0s in forum Ext 2.x: Bugs
    Replies: 0
    Last Post: 20 Oct 2008, 7:01 AM

Tags for this Thread

Posting Permissions

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