1. Home
  2. Tutorials
  3. Working with APIs
  4. Edit or Delete an Array Item

Edit or Delete an Array Item

If your app uses a GET request to display an array of data in a dynamic Element, you can allow the user to select an item and run another request to edit or delete their chosen array entry.

  1. In the page with a GET request returning an array and displaying it in a dynamic Elementhelp (the Data Source should be bound to the dynamic Element), add the request you need for editing or deleting a particular item. get and delete
  2. Your edit or delete endpoint should accept a parameter specifying the item to update, typically this will be an ID, a unique identifier. Bind the parameter to the relevant field from the array being displayed, via the Data Source container. delete id datasource This will pass the ID for the selected item when the user interacts with the dynamic Element.
  3. Add any processing you need when the request response is received into the app, in the Responses or Events.
  4. Run the edit or delete request from the context of the selected item, for example the Tapped Event of a Button inside the Table Cell displaying the data item. run delete
  5. Carry out any Actions you need to update the UI when the item is edited or deleted, for example removing the Table Cell when deleting. remove todo cell

Any Actions added to Events on Elements in (or on) the dynamic child Elementhelp can access the fields from the array item being loaded in each case, so if you have a unique identifier in the array entries, you can pass it into another request that identifies and updates the item. You can see a complete example of the workflow used for deleting an array item in the Checklist Example App.

Was this article helpful to you? Yes No

How can we help?