PDA

View Full Version : how to show fieldLable and field together?



mikeyang
4 May 2010, 7:16 PM
code:

...{
id:"attributes",
fieldLabel:"this is fieldLable",
xtype:"textfield",
hidden:true,
hideLabel:true,
name:"attributes",
}

function showField()
{
field = Ext.getCmp('attributes');
field.enable();
field.show();
}


the function showField can just show the input field, but the fieldLable is still hidden, what should I do?

Animal
4 May 2010, 9:17 PM
http://www.extjs.com/deploy/dev/docs/?class=Ext.layout.FormLayout&member=trackLabels

mikeyang
4 May 2010, 10:10 PM
http://www.extjs.com/deploy/dev/docs/?class=Ext.layout.FormLayout&member=trackLabels

like this :

{
id:"attributes",
fieldLabel:"this is fieldLable",
xtype:"textfield",
trackLabels:true,
name:"attributes",
}

But it failed. I found someone used this: "

Ext.getCmp('attributes').getEl.up('.x-form-item').setDisplayed(false)

but it also failed. My extjs version is 3.1.

Animal
4 May 2010, 11:13 PM
Did you read that documenation? See what class it was for?

Animal
4 May 2010, 11:14 PM
I forget when trackLabels came in. Best upgrade to the latest version.

mikeyang
4 May 2010, 11:45 PM
Did you read that documenation? See what class it was for?

I aslo write "trackLabels:true" in the formPanel like this:


new Ext.form.FormPanel
({
id:'id',
frame:true,
trackLabels: true
... ...

But also failed. whatever in 3.1 or 3.2!

Animal
5 May 2010, 12:58 AM
It only works when programmatically hiding.

You will have to call hide() on the Field.

It's just a legacy thing caused by the FormLayout being responsible for adding labels. trackLabels is a bodge added recently to allow programmatic hiding.

This area will improve in the future.