如何使用Extjs在Message.box中添加标签

时间:2017-02-01 05:08:08

标签: extjs sencha-touch

我想添加标签,显示我在文本区域中写入的字符长度。那么,我如何在EXT.Message.Box中添加标签 这是代码......

function UnLockRemarkWindow(a) {

    var c = Ext.MessageBox.show({
        title: "Version Remarks",
        inputType: "textarea",
        msg: "Please Enter Version Remarks:",
        width: 375,
        buttons: Ext.MessageBox.OKCANCEL,
        multiline: true,
        fn: b,
        icon: Ext.MessageBox.INFO,
        modal: true,
        closable: false,
        allowBlank: false

    });

    c.textField.inputEl.dom.type = "textarea";

这是我想要的图像 enter image description here

2 个答案:

答案 0 :(得分:3)

您需要在消息框的textareafield配置中指定labelitems才能实现此目的,即您需要将textarea和label标识为消息框的子项。

一个工作示例:



Ext.application({
    launch : function() {
        var c = Ext.Msg.show({
        title: "Version Remarks",
        items:[
          {
            xtype:'textareafield',
           labelWrap:true,
             label: "Please Enter Version Remarks:",
            
        },
         {
            xtype:'label',
            html:'0 of 500',
            height:20,
            style:{
                textAlign:'right',
                background:'white'
            }
            },
            ],
       
        width: 375,
        buttons: Ext.MessageBox.OKCANCEL,
        multiline: true,
     
        icon: Ext.MessageBox.INFO,
        modal: true,
        closable: false,
        allowBlank: false

    });
    }
});

<link rel="stylesheet" href="https://cdn.sencha.com/touch/sencha-touch-2.4.2/resources/css/sencha-touch.css">
<script type="text/javascript" src="https://cdn.sencha.com/touch/sencha-touch-2.4.2/sencha-touch-all-debug.js"></script>
&#13;
&#13;
&#13; Ext 4解决方案: MessageBox无法实现。我们需要使用Ext.window来实现这一目标。在textareafield窗口配置中指定labelitems

一个工作示例:

&#13;
&#13;
Ext.application({
    name : 'Fiddle',

    launch : function() {
       Ext.create('Ext.window.Window', {
    title: "Version Remarks",
        items:[
          {
            xtype:'textareafield',
            width:'100%',
             fieldLabel: "Please Enter Version Remarks:",
            
        },
         {
            xtype:'label',
        text:'0 of 500',
            height:20,
             width:'100%',
            style:{
                textAlign:'right',
                display:'block'
            }
            },
            ],
       
        width: 375,
        buttonAlign : 'center',
        buttons:[ { 
            text:'OK'
        },
         {
            text:'Cancel'
        }],
        modal: true,
        closable: false,
}).show();
    }
});
&#13;
<link rel="stylesheet" href="https://cdn.sencha.com/ext/gpl/4.1.1/resources/css/ext-all.css">
<script type="text/javascript" src="https://cdn.sencha.com/ext/gpl/4.1.1/ext-all-debug.js"></script>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

我正在使用ExtJs 4.1版,这是截图 enter image description here