PDA

View Full Version : Hiding A Combobox



jurban
24 Aug 2009, 9:26 AM
I have a form which contains a combobox. Based on choices the user makes I need to hide or show the combobox. The problem is when I hide the combox (combobox.hide()) only the drop down and not the label is hidden. I need to hide the label too. How do I hide the label too?

Sample code copied from my popup:

Ext.onReady(function(){
var fVisible = true;
Ext.QuickTips.init();

// simple array store
var store = new Ext.data.ArrayStore({
fields: ['abbr', 'state', 'nick'],
data : Ext.exampledata.states // from states.js
});

// Create code view Panels. Ignore.
var fForm = new Ext.form.FormPanel({
bodyStyle: 'padding:5px 5px 0',
items: [
{xtype:'combo', id:'myComboBox', fieldLabel: 'Data', width:100, editable:false, forceSelection:true, mode:'local',triggerAction:'all',store:[['Yes','Yes'], ['No', 'No']],},
{xtype:'button', text: 'Hide/Show', handler: buttonHandler}]
});

var GeneralEditWindow = new Ext.Window({
closeAction :'hide',
iconCls :'optsIcon',
title : 'Hide Combobox Sample',
width :300,
height :100,
layout :'fit',
plain :true,
modal :true,
items :[fForm]
});

GeneralEditWindow.show();

function buttonHandler(){
if (fVisible)
{
Ext.getCmp('myComboBox').hide();
fVisible = false;
}
else
{
Ext.getCmp('myComboBox').show();
fVisible = true;
}
}

});

Animal
24 Aug 2009, 9:30 AM
How close are you to releasing code?

Because the next release has a trackLabels: true config on form layout which hides labels when fields are hidden.

If you can't wait, then there are overrides around which fix this.

jurban
24 Aug 2009, 10:20 AM
Next month is when we will be delivering the first RC to our beta customers. What is the work around?

Animal
24 Aug 2009, 1:34 PM
http://extjs.com/forum/showthread.php?p=120152#post120152

jurban
25 Aug 2009, 5:49 AM
Cool, that worked. The boss is happy.

Thanks!

darthwes
13 Oct 2010, 10:13 AM
Special attention given to Animals "on a form layout". Thanks, animal!

senacle
25 Nov 2010, 4:48 AM
Why the code
Ext.layout.FormLayout.prototype.trackLabels = true;
must be specified at the beginning of the entire script ?
In the API, the "true" value is specified to be the default value.

Condor
25 Nov 2010, 6:24 AM
'true' is the default value for Ext 3.3, but for 3.0-3.2 it was 'false'.

senacle
26 Nov 2010, 12:20 AM
And i'm using Ext3.2...so, it's a normal behavior....

Thanks, Condor.