PDA

View Full Version : Grid inside closable window



varunach
18 Apr 2011, 8:58 PM
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:


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:


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

varunach
18 Apr 2011, 10:48 PM
got it working..

m0r14rty
24 Sep 2013, 9:37 AM
Thanks for the awesome solution you posted. :-|

willigogs
25 Sep 2013, 3:00 AM
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.