开发者

How can I make the data in a FormPanel display as text instead of in input boxes?

开发者 https://www.devze.com 2023-02-10 03:52 出处:网络
I have a editable FormPanel that looks like this: I now want to display the same form but so that the data is merely viewable instead of editable, i.e. instead of in textboxes, the data is simply d

I have a editable FormPanel that looks like this:

How can I make the data in a FormPanel display as text instead of in input boxes?

I now want to display the same form but so that the data is merely viewable instead of editable, i.e. instead of in textboxes, the data is simply displayed as text.

I can change the defaultType from textfield to panel but then the data isn't displayed at all.

What type of defaultType do I need so that the data value is simply displayed as text instead of in an input box?

var simple_form = new Ext.FormPanel({
    labelWidth: 75,
    frame:true,
    title: 'Customer Information',
    bodyStyle:'padding:5px 5px 0',
    width: 600,
    height: 600,
    autoScroll: true,
    defaults: {width: 230},
    defaultType: 'textfield',
    items: [{
            fieldLabel: 'Item 1',
            name: 'item1',
            allowBlank:false,
            value:开发者_如何学JAVA 'test'
        },{
            fieldLabel: 'Item 2',
            name: 'item2',
            value: 'test'
        },{
            fieldLabel: 'Item 3',
            name: 'item3',
            value: 'test'
        }, {
            fieldLabel: 'Item 4',
            name: 'item4',
            value: 'test'
            ...


Use Ext.form.DisplayField. The API describes DisplayField as:

A display-only text field which is not validated and not submitted.

Set your defaultType to defaultType: 'displayfield', and the value property to the text you want to display. Take a look at the Composite Fields example. The two DisplayFields are "mins" and "hours".


Having had a quick scan of the Ext.Js documentation (I've never used this library before) it would appear that you need to change...

defaultType: 'textfield',

...to...

defaultType: 'label,

...and...

value: 'test',

...to...

text: 'test',

...which would result in the text fields being replaced by labels - which themselves have labels.

Not sure if it would work, but it has to be worth a try.

The only other issue remaining, would be tro prevent the users form trying to submit the form, as it isn't really a form any more, just an information panel. This statement leads me to suggest that you really ought to be using one of the other Ext.Js components, such as GridPanel.

0

精彩评论

暂无评论...
验证码 换一张
取 消