简体   繁体   中英

How can I make a button be the value in a Ext.FormPanel field row?

I have a FormPanel that looks like this:

var simple_form_left = new Ext.FormPanel({
    frame:true,
    labelWidth: 90,
    labelAlign: 'right',
    title: 'Customer Information',
    bodyStyle:'padding:5px 5px 0',
    width: 290,
    height: 600,
    autoScroll: true,
    itemCls: 'form_row',
    defaults: {width: 160},
    defaultType: 'displayfield',
    items: [{
    ...

now I want to put this button in as a value of one of the rows:

var button = new Ext.Button({
    text: "Click this",
    handler: function() {
        alert('pressed');
    }
});

however when I add it as a value:

在此处输入图片说明

it just shows it as an object:

在此处输入图片说明

I can add it as a full field row like this:

}, {
    fieldLabel: 'Item 15',
    name: 'item15',
    value: 'test'
}, button, {
    fieldLabel: 'Item 17',
    name: 'item17',
    value: 'test'
}, {

but that is not what I want since it needs to have a label:

在此处输入图片说明

How can I add a button in replace of the text in the field row?

Addendum:

Thanks @Tommi, here's the code that I got to work with your solution:

在此处输入图片说明在此处输入图片说明

Add the button object as an item, instead of adding a DisplayField and making the button the value of the DisplayField . And add a FieldLabel on that button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM