|
// Grid’s actionComplete event handler
onActionComplete(args) {
if ((args.requestType === 'beginEdit' || args.requestType === 'add')) {
// New button model
var newFooterButton = { buttonModel: { content: 'custom' }, click: this.onCustomButtonClick.bind(this) };
// Button model is pushed to the dialog’s buttons property and refreshed
args.dialog.buttons.push(newFooterButton);
args.dialog.refresh();
}
}
// Custom button click event
onCustomButtonClick(args) {
alert('Add/Edit dialog custom footer button clicked');
} |
Hi,
unfortunately, the "args.dialog.refresh()" statement has a negative side-effect, i.e. it leads to a misfunctionality of the dialog behavior. When hitting enter in the last field of the dialog-form to save the changes, the save-event gets triggered two times. Therefore, the new record gets created two times, which surely not the expected behavior.
I've added a demo, that show the error.
Step to reproduce the error:
1. Click on "Add" in the grid toolbar.
2. Fill out all fields of the form in the dialog.
3. In the last field of the form ("Ship Country"), hit "Enter" to save the new entry.
4. See the Console -> The "save" event was triggered two times.
Any idea how to solve that? Thanks.
Hi Hee,
You can overcome this behavior by calling the “setButton” method instead of the “refresh” method inside the “actionComplete” event to set the custom buttons. Please refer to the below code example and sample link for more information.
|
actionComplete = {(args) => { if (args.requestType === 'beginEdit' || args.requestType === 'add') { var newFooterButton = { buttonModel: { content: 'custom' }, click: () => console.log('custom button click'), }; args.dialog.buttons.push(newFooterButton); args.dialog.setButton(); } }}
|
Sample: https://stackblitz.com/edit/react-hjr9lo-gmdw5x
Please get back to us if you need further assistance on this.
Regards,
Pavithra S