Crash Course 101
10 modules
5 weeks

Refresh and delete data

Click to copy

How to refresh data in table and delete record in database


Now we can create new records in the database and also see the data from the database in the table. But it would be nice to make a separate business process to update the data in the table at the moment when we need it.

Refresh

Let's add a business process that will be triggered when the Refresh button is clicked, which means it should be executed when the onClick trigger is launched. It will contain already familiar blocks.

  • Table Update Properties to set Loading = true and indicate the fact that data is being loaded.
  • Server request GET /country/ to get data from the database.
  • Table Update Data to display the received data in a table.

Note that it is unnecessary to add a Table Update Properties block at the end of the business process to set Loading = false. Executing the Table Update Data block will fire the onDataUpdate trigger, and the necessary actions will be performed automatically.


Moreover, now we have the opportunity to call the business process by pressing the Refresh button at any time without the need to re-create business processes to update the data. We will use this opportunity to refine the process of adding new data. Let's go back to the business process created in the first half of the module and add one more block to it - Button Click for the Refresh button. Thus, the data in the table will be updated immediately after adding a new record.


Record deletion

Now, to complete the picture, we lack only the ability to remove unnecessary data. To do this, it is best to use the capabilities of the Actions column in the table. Its difference from the other columns is that it does not contain data but action buttons. Let's add a button there and configure it to delete data.


An important feature of the buttons in the Actions column is that when they are pressed, they transmit not only the fact of pressing but also the Record ID, that is, the ID of the element from the table in which row this button is located.

This allows you to make a very simple business process for deleting data:

  1. The trigger fires and sends Record ID.
  2. Runs Server Request DELETE /Country/ to delete data
  3. Update data in table by clicking Refresh button


This completes the creation of the page with the list of countries. Data from the database is displayed in a table, and new countries are added in a modal window, saved in the database, and removed if necessary.

Was this article helpful?
Still looking for an answer?
Join the Community