Our state of the art Gantt chart


Post by swapnakonakanchi »

Hi Team,

I want to open confirmation dialogue when click on button with 'ok' , 'cancel' buttons.

  1. On 'ok' confirmation click, I want to call APi call with parameter.
  2. on 'cancel' confirmation dialogue click, I want to close the confirmation dialogue.
    Please suggest.

Thank you,


Post by alex.l »

Hi swapnakonakanchi,

What dialog are we talking about here? If you meant you want to create your own, here is docs https://bryntum.com/products/gantt/docs/api/Core/widget/MessageDialog#function-confirm
It also contains an example

new Button({
    appendTo : targetElement,
    text     : 'confirm()',
    onClick  : async() => {
        const result = await MessageDialog.confirm({
            title        : 'The big question',
            message      : 'Do one legged ducks swim in circles?',
            okButton     : 'Yes',
            cancelButton : 'No'
        });

    Toast.show(`You answered ${result === MessageDialog.okButton ? 'Yes' : 'No'}`);
}
});

All the best,
Alex


Post by swapnakonakanchi »

Hi Alex,

What you provided that dialogue is fine. I want to call API with parameter. On 'Yes' click. Please suggest.


Post by marcio »

Hey,

You can use the following approach to call an API with the parameter on YES click

const result = await MessageDialog.confirm({
            title        : 'The big question',
            message      : 'Do one legged ducks swim in circles?',
            okButton     : 'Yes',
            cancelButton : 'No'
        });

if(result === MessageDialog.okButton) {
	// call API with parameter
}

Is that what you're looking for?

Best regards,
Márcio


Post by swapnakonakanchi »

Yes, But not getting how to call API in that, I tried as below but not working. Please provide sample code.

 if (result === MessageDialog.okButton) {
              // call API with parameter
              transport: {
                url: '/Process/ModelTaskDependencies/Sync',
                method: 'POST',
              params: {
                processModelId: null,
              }
              }
            }

Post by marcio »

Hey swapnakonakanchi,

That's a configuration that you need to put inside the Gantt project configuration, to sync you need to use the sync function https://bryntum.com/products/gantt/docs/api/Gantt/model/ProjectModel#function-sync

You can see an example of that configuration checking the Backend in PHP demo.

Best regards,
Márcio


Post Reply