How to control the delete button on the react-admin list? I need to set a confirmation message before deleting a record. Below is the screenshot of the list:
Asked
Active
Viewed 953 times
1
-
Similar question: https://stackoverflow.com/questions/60996777/how-to-change-the-delete-confirmation-dialog-title – MaxAlex Jul 09 '20 at 13:44
1 Answers
0
You can use npm i sweetalert2
like :
import Swal from "sweetalert2"; import axios from "axios";
onDeleteClick( pk) {
Swal.fire({
text :"Are you sure?,
title: "You won't be able to ,
type: "question",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: Yes!,
cancelButtonText: No!
}).then(result => {
if (result.value) {
axios
.delete(
`api ,
)
.then(res => {
Swal.fire({
title: "Deleted",
type: "success",
text: " Deleted Successfully !!",
showConfirmButton: false,
timer: 2000
});
})
.catch(err => {
console.log(err);
Swal.fire({
title: " Deleted",
type: "error",
text: "Error While deleting ??",
timer: 3000
});
});
}
});
}

Piotr
- 145
- 4
- 16
-
but, how i can access this function onDeleteClick ? I have a List and Datagrid component
} filter={ {UserId : usuario }} > – user3646212 Jul 09 '20 at 17:20