Showing posts with label field. Show all posts
Showing posts with label field. Show all posts

Wednesday, July 9, 2008

Hide/Show FieldLabel in ExtJs form

This is an overriding function to enable hide/show fieldLabel in ExtJs field form.
The current release of ExtJs 2.1 does not support it.

You can use the function hideItem and showItem in order to show/hide the form field.

Put this function in a javascript file eg. ext-override.js
Then include this file into your html file containing ExtJs form.
Ext.override(Ext.form.Field, {
hideItem :function(){
this.formItem.addClass('x-hide-' + this.hideMode);
},

showItem: function(){
this.formItem.removeClass('x-hide-' + this.hideMode);
},
setFieldLabel: function(text) {
var ct = this.el.findParent('div.x-form-item', 3, true);
var label = ct.first('label.x-form-item-label');
label.update(text);
}
});