hello ! is it possible to have my custom modal here instead of the generic modal from the grid ?
I want to have my own modal instead of ( Are you sure you want to Delete Record ? )
How i can acheive it
|
<ejs-dialog #dialog id='dialog' #ejDialog [visible]='false' isModal='true' target='#dialog-target' width='300px'>
</ejs-dialog> |
|
public ngOnInit(): void {
this.toolbar = [{ text: "Custom Delete", tooltipText: "Delete", prefixIcon: "e-delete", id: "custom-delete"}];
} |
|
public ngOnInit(): void {
// Buttons for confirmation dialog
this.buttons = [
{
buttonModel: {
content: "OK",
cssClass: "e-flat",
isPrimary: true
},
click: this.confirmationClick.bind(this)
},
{
buttonModel: {
content: "Cancel",
cssClass: "e-flat"
},
click: this.cancelClick.bind(this)
}
];
// Button for dialog when no records are selected on clicking delete
this.buttons1 = [
{
buttonModel: {
content: "OK",
cssClass: "e-flat",
isPrimary: true
},
click: () => {
this.dialogInstance.hide();
}
}
];
}
// Ok button click function
confirmationClick() {
// Hides the dialog
this.dialogInstance.hide();
// Deletes the selected record from Grid
this.gridInstance.deleteRecord();
}
// Cancel button click function
cancelClick(args) {
// Hides the dialog
this.dialogInstance.hide();
} |
|
// Grid’s toolbarClick event function
toolbarClick(args) {
// Assigning buttons to dialog instance
this.dialogInstance.buttons = this.buttons;
if (args.item.id == "custom-delete") {
// Updates the dialog content
if (this.gridInstance.getSelectedRecords().length !== 0) {
this.dialogInstance.content = "Do you wish to delete the selected record ?";
// Displays the dialog
this.dialogInstance.show();
} else {
// Updates the dialog content
this.dialogInstance.content = "No record selected for deletion";
// Updates the button model for this scenario
this.dialogInstance.buttons = this.buttons1;
// Displays the dialog
this.dialogInstance.show();
}
}
} |