Delete selected data from the data grid

0
I have a data grid that is imported from an excel file using ExcelImporter. I want to select some of the data that has been imported and delete them, but I don’t know how.   I have created a “Delete All” button which calls to a microflow that retrieves the entire list and deletes it. But I want to create a “Delete” button that deletes only the selected data (single or multiple). I tried to create a microflow for deleting a single data, but when I tried to edit the “Retrieve Objects” on the microflow, I only had Range options of “All”, “First”, and “Custom”. “First” deletes only the very first data in the grid, but I want to delete the selected data, which can be in the middle or the bottom of the list. I assume “Custom” range is the one to retrieve the selected data, but I am not sure how to put in “Offset” and “Amount”.   
asked
2 answers
0

Hi Alex,

 

depending on if you use data grid or data grid 2 it could be slightly different but both have the option of a single-select or multi-select. The old data grid even has the delete option by default (only visible/usable with correct entity access).

 

If you add a button to the data grid calling a microflow you will have a object or list (single/multi-select) parameter in the microflow available (which reflects your selection). 

 

You can then just delete the input object(s). Make sure to have the microflow access configured (otherwise the button won’t be visible) and maybe add a confirmation (to make sure users don’t delete by accident).

 

Cheers,

Jan

 

E.g. with DataGrid2:

 

answered
0

Hi Alex,

  • Ensure you have a data grid widget in your Mendix application that displays the data you want to delete, bound to a specific entity in your domain model.

  • Create a new microflow named "DeleteSelectedItems."

  • In the microflow, add a parameter of the entity type corresponding to the data displayed in your data grid. This parameter will receive the selected items for deletion.

  • Inside the microflow, add a loop (e.g., "For Each" activity) to iterate over the selected items you want to delete.

  •  Within the loop, use the "Delete" activity to delete each selected entity.

  • In your data grid, create a "Delete" button (or another button as desired). Configure the button to trigger the "DeleteSelectedItems" microflow and pass the selected items as a parameter.

answered