0

I want to display the label on top of text field, but it is not displaying. Below is the code.(in fact the below code displays the label at the right side of text field).I am using extjs 3.4, note : Using form panel is also not working as expected (have pasted the code below)

Any help is much appreciated.

Ext.onReady(function () {
    var contentsPanel = new Ext.Panel({
        labelAlign: 'top',
        renderTo: Ext.getBody(),
        layout: 'form',
        defaultType: 'textfield',

        items: [{
            fieldLabel: 'First Name',
            name: 'first'
        }]
    });
    contentsPanel.show();
});   

Ext.onReady(function () {
    var contentsPanel = new Ext.form.FormPanel({
        renderTo: Ext.getBody(),
        defaultType: 'textfield',
        labelAlign: 'top',
        items: [{
            fieldLabel: 'First Name',
            name: 'first',
            labelAlign: 'top'
        }]
    });
    contentsPanel.show();
});
4

1 回答 1

2

labelAlign 是字段的属性,而不是面板属性。需要配置字段:

items:[{
    fieldLabel: 'FirstName',
    labelAlign: 'top',
    name: 'first'
}]

如果要为所有面板字段设置 labelAlign,可以在面板配置中添加:

var contentsPanel = new Ext.Panel({
    fieldDefaults: {
        labelAlign: 'top'
    },
    ...
于 2013-04-18T11:11:28.790 回答