在ExtJs中,如何使用图标作为"值" " displayfield"?

时间:2015-01-07 10:59:41

标签: extjs

我希望图标显示为"值"表格" displayfield"。这是显示只读值,如true / false和yes / no,带有"刻度线/十字标记"等图标。怎么做?标签上有很多帖子,但这不是我想要的。我需要一个" fieldLabel"然后是图标(虽然不是必须使用表格,但我可以使用任何组件)。

2 个答案:

答案 0 :(得分:2)

是的,我们可以尝试使用我的示例,我也附上了截图。

            Ext.onReady(function () {
        Ext.create('Ext.form.Panel', {
            renderTo: Ext.getBody(),
            width: 200,
            height: 150,
            bodyPadding: 10,
            title: 'Final Score',
            items: [{
                xtype: 'displayfield',
                fieldLabel: 'home ',
                name: 'home_score',
                value: '<img src="home.png"></img> '
            }, {
                xtype: 'displayfield',
                fieldLabel: 'Visitor ',
                name: 'visitor_score',
                value: '<img src="visitor.png"></img>'
            }],
            buttons: [{
                text: 'Update'
            }]
        });
        });

只需在代码中更改图片的路径。如果您没有使用表单,请在标签字段中应用相同的内容。enter image description here

答案 1 :(得分:0)

最后,我在表单面板中执行了以下操作以使其正常工作:

        {
            xtype: 'fieldcontainer',
            fieldLabel: 'Label 1',
            flex: 1,
            name: 'Name 1',
            items: [{
                xtype: 'image',
                glyph: 'something@FontAwesome'
            }]
        },{
            xtype: 'fieldcontainer',
            fieldLabel: 'Label 2',
            flex: 1,
            name: 'Name 2',
            items: [{
                xtype: 'image',
                glyph: 'something@FontAwesome'
            }]
        }

我把Ext.Img放在form-panel类的'requires'中。