Page 1 of 1

Add custom HTML to the MessageDialog

Posted: Wed Feb 22, 2023 4:29 am
by shimnx

I want to add Radio to MessageDialog, I try to set contentElement and content, but it doesn't work, this is my code, please ask how to use it

 const result = await MessageDialog.prompt({
        title: 'information',
        message: `Please confirm moving ${taskRecords.map(t => `"${t.name}"`).join(', ')} to ${targetColumn.text}?`,
        okButton: 'Confirm',
        content:`<div>111</div>`,
        cancelButton: 'Cancel'
      });

Re: Add custom HTML to the MessageDialog

Posted: Wed Feb 22, 2023 6:54 am
by alex.l

Hi,

https://bryntum.com/products/gantt/docs/api/Core/widget/MessageDialog is a subclass of Popup with pre-defined set of widget in it.

If you want to implement own set of elements, better to use https://bryntum.com/products/gantt/docs/api/Core/widget/Popup
with own https://bryntum.com/products/gantt/docs/api/Core/widget/Popup#config-items


Re: Add custom HTML to the MessageDialog

Posted: Wed Feb 22, 2023 7:32 am
by shimnx

I need my method to be synchronous, but how does Popup make it synchronous because I need the user to return when they click the confirm button

 async beforeTaskDrop({ taskRecords, targetColumn, targetSwimlane }) {
  const result = await MessageDialog.prompt({
        title: 'information',
        message: `Please confirm moving ${taskRecords.map(t => `"${t.name}"`).join(', ')} to ${targetColumn.text}?`,
        okButton: 'Confirm',
        content:`<div>111</div>`,
        cancelButton: 'Cancel'
      });
 	if (result === MessageDialog.okButton) {
     		return true
            } 
 }

Re: Add custom HTML to the MessageDialog

Posted: Wed Feb 22, 2023 7:53 am
by alex.l

no, Popup is not async by default. But you can easily implement it by your own, all you need is create a JavaScript Promise, resolve/reject it inside ok/cancel methods of your button, and add await instruction in your code.


Re: Add custom HTML to the MessageDialog

Posted: Wed Feb 22, 2023 8:02 am
by shimnx

Can the MessageDialog add components? radio, for example, still uses bryntum components rather than customizations

items    : [
        {
            tag   : 'p',
            style : 'font-weight:500',
            html  : 'Do you need jQuery in your web app?'
        },
        {
            type         : 'radio',
            name         : 'radios',
            text         : 'No',
            checked      : true,
            checkedValue : 'A'
        },
        {
            type         : 'radio',
            name         : 'radios',
            text         : 'Probably not',
            checkedValue : 'B'
        },
        {
            type         : 'radio',
            name         : 'radios',
            checked      : true,
            text         : 'Unlikely',
            checkedValue : 'C'
        }
    ]

Re: Add custom HTML to the MessageDialog

Posted: Wed Feb 22, 2023 8:24 am
by alex.l

Hi,

As I said before, MessageDialog is a Popup with pre-defined set of widgets in it. You need to use Popup class with desired items.