2011-02-15 139 views
0

我有一個FormPanel中看起來像這樣:如何讓一個按鈕成爲Ext.FormPanel字段行中的值?

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: [{ 
    ... 

現在我想把這個按鈕的其中一列的值:

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

,當我將其添加爲一個值:

enter image description here

它只是表明它作爲對象:

enter image description here

我可以將其添加爲滿場的行這樣的:

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

但是這不是我想要的,因爲它需要有一個標籤:

enter image description here

如何添加按鈕來替換字段行中的文本?

附錄:

感謝@Tommi,下面是我用你的解決方案,工作代碼:

enter image description here enter image description here

回答

1

添加button對象作爲一個項目,而不是添加DisplayField並製作DisplayField的按鈕value。並在該按鈕上添加一個FieldLabel

相關問題