Have a doubt with conditional visibility of button widget

0
So I am developing a project where we track task . My aim right now is that if there are only one task the delete button should disappear, else it should show and by default one empty task get generated automatically. I can''t delete that. To overcome that UX issue, I am planning to do this. How to do it. I have tried establishing this using a microflow but it wasn't working
asked
3 answers
0

Hi Ayman,
I would suggest you to create a helper entity and have a boolean attribute in it.
1. Use a dataview in the page and give the helper entity as the datasource for the dataview
2. Inside the datagrid2 use the microflow for retreiving the data also pass the helper entity as a parameter.
3. Here comes the condition, Use change object for the helper entity and put a condition stating (if the list is greater than 1 then put true else false)
4. Now use the helper entity boolean value in the button's visibility.

Check this method and let me know if you face any issues

answered
0

Another option would be, create a boolean page parameter and do the count within the calling nanoflow/microflow of the page. ( Count > 1 ). When you delete of add something on the page, close and reopen page (will trigger the update).

answered
0

This can also be handled from the client side if your goal is only to hide the delete button for the first task.

For a List View, since Mendix renders it as ul > li, you can hide the delete button for the first row like this:


.mx-listview.task-list {
  > ul > li:first-child {
    .delete-task-btn,
    .mx-name-deleteButton {
      display: none !important;
    }
  }
}

For Data Grid 2, you can target the first rendered row like this:


.widget-datagrid.task-grid {
  .widget-datagrid-grid-body {
    .tr:first-child {
      .delete-task-btn,
      .mx-name-deleteButton {
        display: none !important;
      }
    }
  }
}

This is a simple UI-only solution. If you want to strictly prevent deletion of the first/default task, then it is better to also enforce it in the microflow or nanoflow.

answered