PDA

View Full Version : Extjs 4.2 disable works, enable doesn't



sciencebitch
25 Oct 2013, 3:33 AM
I have

borderLayout = Ext.create('Ext.window.Window', { ... etc.


Ext.getCmp('main-window').setDisabled(true);
borderLayout['disable']();

both works, but neither


Ext.getCmp('main-window').setDisabled(false);
borderLayout['enable']();

both return error
TypeError: this["enable"] is not a function.
Something wasn't uploaded properly, or there is other method for enabling disabled window? Or I'am just a sucking scumbag?



<html>

<head>
<title>TEST</title>
<link rel="stylesheet" type="text/css" href="css/ext-theme-gray-all.css" />
<script src="js/ext-all.js"></script>
<script>
window.onload = function () {
var regions = {},
borderLayout,
filemenu,
toolbar;

filemenu = Ext.create('Ext.menu.Menu', {
items: [{
text: 'Open'
}, {
text: 'Exit'
}]
});

toolbar = Ext.create('Ext.toolbar.Toolbar', {
id: 'topmenu',
text: 'File',
items: [filemenu]
});


regions.northRegion = Ext.create('Ext.panel.Panel', {
title: 'Query',
region: 'north',
height: 100,
split: true,
bodyStyle: 'padding:0;margin:0',
layout: 'fit',
items: [{
xtype: 'textareafield',
grow: true,
width: '100%',
height: '100%',
name: 'query-area'
}]

});
regions.southRegion = Ext.create('Ext.panel.Panel', {
title: 'south Region',
region: 'south',
height: 100,
split: true
});
regions.westRegion = Ext.create('Ext.panel.Panel', {
title: 'Databases',
region: 'west',
height: 100,
width: 200,
layout: 'accordion',
autoScroll: true,
collapsible: true,
split: true
});
regions.eastRegion = Ext.create('Ext.panel.Panel', {
title: 'Tables',
region: 'east',
width: 200,
collapsible: true,
split: true
});
regions.centerRegion = Ext.create('Ext.panel.Panel', {
title: 'Result Set',
region: 'center',
layout: 'fit'
});

borderLayout = Ext.create('Ext.window.Window', {
id: 'main-window',
width: '100%',
height: '100%',
title: 'Border Layout',
maximizable: true,
closable: false,
layout: 'border',
resizable: false,
closable: false,
draggable: false,
shadow: false,
enable: false,
defaults: {
xtype: 'panel'
},
tbar: [{
xtype: 'button',
text: 'File',
menu: [{
text: 'Open',
handler: function () {
alert('Open file');
}
}, {
text: 'Exit'
}]
}],
items: [regions.northRegion, regions.southRegion, regions.westRegion, regions.eastRegion, regions.centerRegion]
});

//Ext.getCmp('main-window').setDisabled(true);
Ext.getCmp('main-window').setDisabled(false);
Ext.EventManager.onWindowResize(function (w, h) {
borderLayout.doComponentLayout();

});

borderLayout.show();
}
</script>

<body></body>

</html>


Can't put code when edit, sorry

Gary Schlosberg
25 Oct 2013, 9:14 AM
I believe the problem here is the 'enable: false' setting you have on the window. I don't see it as an available config in the Ext.window.Window docs (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.window.Window), and when I remove it from your code the enabling of the window works as expected.

https://fiddle.sencha.com/#fiddle/176

sciencebitch
29 Oct 2013, 11:11 PM
I don't get it.

target.setDisabled(true);
disable target

target.setDisabled();
enable target
So, I do expect that switch should be true-false, not true-null. Just want to know, what is the reason to use null argument instead of false? (Reasons, except internal structure of library)

Gary Schlosberg
6 Nov 2013, 1:25 PM
So setDisabled(false) doesn't enable the window for you?

sciencebitch
7 Nov 2013, 12:12 AM
Well, no. I'v mentioned that in the first post. setDisabled(false) throws error, setDisabled(null) is ok

Gary Schlosberg
7 Nov 2013, 5:57 AM
In which browser are you seeing this behavior?

sciencebitch
7 Nov 2013, 9:46 PM
I's even worse now. I will try to find bug harder, because I now have two projects, they use equal layout, but one works fine with setDisabled(false), and other doesn't.

sciencebitch
7 Nov 2013, 9:55 PM
I got it; I had error: created window with option

disable: false,
...

instead of

disabled: false,
...

And if I add option "enable" or "disable", doesn't matter, it doesn't work. If I omit them, or write "enabled" or "disabled", then it works fine too.