PDA

View Full Version : Doest not work"second time"



Override
22 Dec 2009, 6:18 AM
Hi.
I have CellSelection model, which isn't works after window with grid was closed and opened again.
Grid code below:


MyNS.GetCellSelectionModel=function()
{
return new Ext.grid.CellSelectionModel(
{
listeners:
{
beforecellselect: function(sm, rowIndex, colIndex)
{...}
}
}
});
... and grid definition:
MyNS.FileUploader = Ext.extend(
Ext.form.FormPanel,
{
items:
[
{
xtype: 'grid',
...
sm: MyNS.GetCellSelectionModel()
}
]
}
(beforecellselect does not executed second time). Everything else works fine.

And another question:
Sample 1:
items:
[
new Ext.grid.GridPanel()
]
Sample 2:
items
[
{ xtype: 'grid' }
]
Differences?
Ok, in first sample I have instance, in second - declaration. But how Ext treat it? Do I have disposed reference after window opened second time?

p.s. Just show me right direction. Thanks.

22 Dec 2009, 8:32 AM
Moved to the help section, please post here with questions from now on.

Override
22 Dec 2009, 8:43 AM
Thanks, but answer will be better :)

22 Dec 2009, 9:01 AM
it seems that you are most likely not recreating the grid properly

Override
22 Dec 2009, 9:16 AM
Yes, I just have grid declaration. Is this not enough? I think that Ext creating grid each time when I constructing container object (window, in my example).


items:
[
{
xtype: 'grid',
...
sm: MyNS.GetCellSelectionModel()
}
]
}

seems that Ext most likely not recreating the selection model properly :)
Could you tell me, how I should rewrite GetCellSelectionModel() for fix "second time"?

22 Dec 2009, 9:23 AM
No, you're extending incorrectly.

You need to set the items property either in the constructor or the initComponent.



var myComponent = Ext.extend(Ext.Window, {
width : 100,
height : 100,
initComponent : function() {

myComponent.items = {html: 'some new panel ' + new Date().format('U')};

myComponent.superclass.initComponent.call(this);
}

});

Ext.onReady(function() {
new myComponent().show();

});

Override
22 Dec 2009, 10:19 AM
I didn't wrote full implementation, however:


MYNS.FileUploader = Ext.extend(
Ext.form.FormPanel,
{
fileUploaderConfig:
{
fileUpload: true,
allowAdd: true,
labelWidth: 150,
buttonAlign: 'right',
items:
[
{
xtype: 'grid',
id: MYNS.Res.FileUploader.IDPrefix + "FilesGrid",
border: false,
defaults: { anchor: "100%" },
height: 300,
sm: MYNS.UI.GetCellSelectionModel()
}
]
},
constructor: function(config)
{
//same .ctor logic, but few items changed according internal logic
var resultConfig = Ext.apply({}, this.fileUploaderConfig);
MYNS.FileUploader.superclass.constructor.call(
this,
MYNS.ApplyConfigWithItems(resultConfig, config));
}
});
FileUploader is inside window, instantiated according pattern described.
All code works fine in first window. After window closed and opened, only cell click does not work.
I think problem is inside selection model initialization.
Or you talking about differences between items array initialization? (In your sample items created inside .ctor)