【问题标题】:How do I make a button in an Ext.FormPanel be width=100% with red text?如何使 Ext.FormPanel 中的按钮宽度 = 100% 并带有红色文本?
【发布时间】:2011-07-05 21:20:02
【问题描述】:

我有一个表格,最后有一个按钮,如下所示:

var simple_form_right = new Ext.FormPanel({
        frame:true,
        labelWidth: 90,
        labelAlign: 'right',
        title: 'Orderer Information',
        bodyStyle:'padding:5px 5px 0',
        width: 300,
        height: 600,
        autoScroll: true,
        itemCls: 'form_row',
        defaultType: 'displayfield',
        items: [{
                fieldLabel: 'Customer Type',
                name: 'customerType',
                allowBlank:false,
                value: 'Company'
            }, .... {
                fieldLabel: 'Item 21',
                name: 'item21',
                value: 'test'
            },
            new Ext.Button({
                text: "Cancel Order",
                style: 'width: 100%; color: red',
                handler: function() {
                    alert('pressed');
                }
            })
        ]
    });

按钮可以工作,但正如样式信息尝试所表明的那样,我希望按钮在表单中延伸并具有红色文本

如何使按钮的宽度延伸到整个表单并在按钮内显示红色文本?

附录

Robby 的解决方案 100% 有效:

...
}, {
    fieldLabel: 'Item 20',
    name: 'item20',
    value: 'test'
}, {
    fieldLabel: 'Item 21',
    name: 'item21',
    value: 'test'
}, {
    xtype: 'button',
    text: '<span style="color:red">Cancel Order</span>',
    anchor: '100%',
    handler: function() {
        alert('pressed');
    }
}

【问题讨论】:

    标签: javascript forms button extjs


    【解决方案1】:

    将您的按钮定义更改为。

    {
        xtype: 'button',
        text: '<span style="color:red;">Cancel Order</span>',
        anchor: '100%'
        handler: function() { alert('pressed') };
    }
    

    要使锚属性起作用,您的按钮不能位于面板的“按钮”数组中。

    【讨论】:

      猜你喜欢
      • 2012-12-21
      • 1970-01-01
      • 2020-05-29
      • 2021-05-25
      • 2016-05-28
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 2017-07-21
      相关资源
      最近更新 更多