简体   繁体   English

ExtJs(v 6.0.0,经典)带有自定义文本和表单的消息框

[英]ExtJs (v 6.0.0, classic) Message box with custom text and forms

I want to have a workflow in ExtJs where I display a modal dialog in which someone needs to enter some data into a form and then presses the 'OK' to move on. 我想在ExtJs中创建一个工作流,在其中显示一个模式对话框,在该对话框中,有人需要将一些数据输入表单,然后按“确定”继续。

As far as I have seen the basic Ext.MessageBox could be a good fit in the first place. 据我所知,基本的Ext.MessageBox首先可能很合适。

But the documentation just describes a 'message' property. 但是文档仅描述了“消息”属性。 This one seems to be very restricted to me. 这似乎仅限于我。

What I need is a custom form to be displayed as main body. 我需要的是自定义表单,以显示为主体。 A custom form with three toggle buttons and a textarea. 具有三个切换按钮和一个文本区域的自定义窗体。
Not some prefigured single and simple textfields or textareas. 没有一些预先准备好的单一和简单文本字段或文本区域。

How can that be done? 那怎么办? - Is the Ext.MessageBox not the right item to use? -Ext.MessageBox不是正确使用的项目吗?

Building a modal window does not feel correct as well since there are a lot of configurations which need to be done on top. 建立模态窗口也不太正确,因为需要在顶部进行很多配置。

Did I miss something? 我错过了什么? Is the problem understandable? 问题是可以理解的吗?

What I have so far: 到目前为止,我有:

Ext.Msg.show({

        title:'Title',
        message: 'Here we should see another form with 3 togglable buttons and a textarea...',

        buttons: Ext.Msg.OK,
        icon: Ext.Msg.QUESTION,

        fn: function(btn) {
            console.log('button: '+ btn)
            if ( btn !== 'ok' ) { return; }
        },
    });

对话

And this is somewhat what it should look like... 这看起来应该是...

在此处输入图片说明

Of course it would be nice to react on the user's input after OK is pressed. 当然,按下OK后对用户的输入做出反应会很好。 Any hints are welcome as well. 任何提示也欢迎。

I added showDialog function to window class by overriding it. 我通过覆盖将showDialog函数添加到窗口类。

You can call showDialog by passing parentWindow and only parentWindow will be masked 您可以通过传递parentWindow来调用showDialog,只有parentWindow会被屏蔽

showDialog: function(parentWindow) {
    var me = this;

    me.parentWindow = parentWindow;
    parentWindow.disableByMask();

    parentWindow.on({
        show: me.onParentShown,
        destroy: me.onParentDestroyed,
        hide: me.onParentHid,
        maskclick: me.onParentMaskClicked,
        scope: me
    });

    me.show();
},

disableByMask: function() {
    var me = this;

    me.setLoading("");
    me.loadMask.msgWrapEl.hide();

    var el = me.loadMask.getEl();
    el.setStyle({ opacity: 0 });

    el.on({
        mousedown: function () {                
            el.setStyle({ backgroundColor: "#CCCCCC", opacity: .5 });                
            me.fireEvent("maskclick", me, el);
        },
        mouseup: function () {
            el.setStyle({ backgroundColor: "#FFF", opacity: 0 });
        }
    });
},

hideDisabledMask: function() {
    var me = this,
        el = me.loadMask.getEl();

    me.setLoading(false);
    el.setStyle({ backgroundColor: "rgba(204, 204, 204, .5)", opacity: 1   });

    me.loadMask.msgWrapEl.show();
    me.loadMask.msgEl.show();
    me.loadMask.msgTextEl.show();
},

onParentShown: function() {
    var me = this;
    me.show();
},

onParentDestroyed: function() {
    var me = this;
    me.close();
},

onParentHid: function() {
    var me = this;
    me.hide();
},

onParentMaskClicked: function() {
    var me = this;
    me.zIndexManager.bringToFront(me);
},

onDestroy: function() {
    var me = this;

    if (me.parentWindow) {
        me.parentWindow.hideDisabledMask();
        me.parentWindow.un("show", me.onParentShowed, me);
        me.parentWindow.un("destroy", me.onParentDestroyed, me);
        me.parentWindow.un("hide", me.onParentHid, me);
        me.parentWindow.un("maskclick", me.onParentMaskClicked, me);
    }

    me.callParent();
}

Instead of using Ext.MessageBox, you have to create a customized pop up window with 3 buttons and a text area as items and a tbar button with text OK . 代替使用Ext.MessageBox,您必须创建一个自定义弹出窗口,其中包含3个按钮和一个文本区域作为项,以及一个tbar按钮,其文本为OK For that button you have to use handler for your necessary actions ie., 对于该按钮,您必须使用处理程序来执行必要的操作,即

tbar =[
    {
        text: 'Ok',
        handler: function() {
            var textAreaValue = Ext.getCmp('text-area-id').getValue();
        }
    }
];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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