Adding the delete functionality
Items can be deleted from the database by sending the DELETE
method request to the http://localhost:8080/api/cars/{carId}
endpoint. If we look at the JSON response data, we can see that each car contains a link to itself, which can be accessed from the _links.self.href
node, as shown in the following screenshot:
Figure 13.8: Car link
We already used the link
field in the previous section to set a unique ID for every row in the grid. That row ID can be used in deletion, as we will see later.
The following steps demonstrate how to implement the delete functionality:
- First, we will create a button for each row in the MUI
DataGrid
. When we need more complex cell content, we can use therenderCell
column property to define how a cell’s contents are rendered.Let’s add a new column to the table using
renderCell
to render thebutton
element. Theparams
argument that is passed to the function is a row object that...