PDA

View Full Version : [CLOSED]Hiding form elements doesn't work correctly



zhegwood
3 Mar 2010, 3:02 PM
Ext version tested:

Ext 3.1.1


Adapter used:

ext


css used:

only default ext-all.css




Browser versions tested against:

FF3 (firebug 1.3.0.10 installed)


Operating System:

Windows Vista


Description:

Calling hide() on a form item only hides the element and not the label. Prior to Ext 3 calling hide on a form item would hide the entire thing.


Test Case:




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="ext-3.1.1/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="ext-3.1.1/ext-all-debug.js"></script>
<link rel="stylesheet" href="ext-3.1.1/resources/css/ext-all.css"type="text/css" />
</head>
<body></body>
</html>
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.namespace("AV");
AV.ViewPort = new Ext.Viewport({
layout: "fit",
items: new Ext.form.FormPanel({
items: [
new Ext.form.TextField({
id: "textfield",
fieldLabel: "Awesome",
//hidden: true //this also only hides the form field and not the label
}),
new Ext.Button({
text: "hide it",
listeners: {
click: function() {
Ext.getCmp("textfield").hide();
}
}
})
]
})
});
});
</script>


See this URL : http://


Steps to reproduce the problem:

Create an html page with the code above


The result that was expected:

clicking the button hides the entire form element, not just the input


The result that occurs instead:

clicking the button hides only the input and not the label


Screenshot or Video:

attached


Debugging already done:

none


Possible fix:

This is what I've been doing, but it won't work if the fields aren't in a form layout


listeners: {
render: function(obj) {
var ct = obj.el.up('.x-form-item');
ct.setStyle("display","none");
},
scope: this
}

evant
3 Mar 2010, 3:29 PM
Actually the default behaviour has never been to hide labels, perhaps you were using a custom override.

Anyway, this behaviour now exists in 3.1+, http://www.extjs.com/deploy/dev/docs/?class=Ext.layout.FormLayout&member=trackLabels

Marking as closed.

zhegwood
4 Mar 2010, 8:03 AM
Weird, yeah must have been. Hmm. Thanks for the response Re: trackLabels. Works like a champ!