PDA

View Full Version : How to disable parent window



ondra.cz
24 Nov 2013, 2:42 PM
Hi,
I'm trying to create and show window as child of another window and simultaneously disable the parent window (simulate modal window only for parent window).

This code worked in Ext 4.1 but is not working in 4.2.


parentWindow.add(Ext.widget('window', {
closeAction : 'hide',
border : false,
items : [Ext.widget('form')]
}));
parentWindow.disable();


This code disable also the created form window. Do you have any advice how to solve it in Ext 4.2.1?

scottmartin
25 Nov 2013, 2:24 PM
I pasted this in our fiddle: https://fiddle.sencha.com/#home

Only the parent is disabled .. is this what you meant?



Ext.application({
name: 'Fiddle',

launch: function() {

var parentWindow = Ext.create('Ext.window.Window', {
title: 'Parent Window',
height: 200,
width: 400,
layout: 'fit',
items: []
}).show();


var childWindow = Ext.create('Ext.window.Window', {
title: 'Child Window',
height: 100,
width: 200,
items: []
}).show();

parentWindow.add(childWindow);
parentWindow.disable();

}
});

ondra.cz
25 Nov 2013, 11:50 PM
Hello scottmartin,
thank you for answer. Problem is when I have form in this child window. This form is than disabled for some reason. This code worked in Ext 4.1.1.

Try put this code in jsfiddle:


Ext.application({
name: 'Fiddle',

launch: function() {

var parentWindow = Ext.create('Ext.window.Window', {
title: 'Parent Window',
height: 200,
width: 400,
layout: 'fit',
items: []
}).show();


var childWindow = Ext.create('Ext.window.Window', {
title: 'Child Window',
height: 100,
width: 200,
layout: 'fit',
items: [{
xtype: 'form',
items: [{
xtype : 'textfield',
name : 'text',
fieldLabel : 'Text',
labelWidth : 50
}]
}]
}).show();

parentWindow.add(childWindow);
parentWindow.disable();

}
});

scottmartin
26 Nov 2013, 5:44 AM
I see when you mean. I am trying to decide if 4.1 was broken, or 4.2

Meaning .. If childWindow belongs to ParentWindow and you disable parentWindow, all child items should be disabled?

ondra.cz
26 Nov 2013, 5:53 AM
No, all child items should be enabled. I want to disable parentWindow (for example to prevent changing selection in grid) and enable form in childWindow to fill and send by user.

scottmartin
26 Nov 2013, 5:59 AM
I understand what you want, but I need to discuss this with dev to determine the correct behavior.

scottmartin
26 Nov 2013, 6:11 AM
If you look at getChildItemsToDisable, you will see it queries for form items


getChildItemsToDisable: function(){
return this.query('[isFormField],button');
},


So you would have to override this.

If you simply remove the parentWindow.add(childWindow), do you not get the behavior you want? Why are you adding it as a child in the first place?

Are you not using model to only mask the window and not the entire body?

ondra.cz
26 Nov 2013, 6:45 AM
I use this model in Web Desktop Application. In Ext 4.1 adding of childWindow as child of parentWindow helped me to easily mask (disable) only the parent window and not all Desktop (in case of modal window) and also solved behavior when in minimize parentWindow with opened childWindow into the taskbar (childWindow was hidden "automaticaly"). Another advantage was that i could have childWindow as widget which automaticaly cares about disabling and enabling parentWindow (by selector ".up('window')". Also childWindow wasn't displayed in taskbar.
If I remove parentWindow.add(childWindow), I will have to care about these behaviours in all windows separately.