Show button when list is empty

0
When a listview contains no items, it says "No items found" Is there any way to show a clickable Button instead which triggers a microflow? The button should only be displayed in the ListView and only if it does not contain any items.
asked
4 answers
1

I don’t think you can do exactly what you described with ListView 1.0. There’s quite few options, but if you would prefer to continue using standard Mendix components, you could:

 

  1. Stick to Listview 1.0

(a) Create a Non-persistent entity ‘Helper’, with a Boolean ‘hasItems’ or something like that.

(b) Change the page so that Helper is one of the first objects loaded on the page (either as an input parameter, or as a data source microflow)

(c) Whatever option you use in (b), update hasItems by checking if your Listview has any items

(d) If hasItems = true, show Listview. If hasItems = false, hide ListView and show your button which triggers microflow

 

  1. Use DataGrid2 or Gallery instead

Both have an Empty Message property which allows you to customise what to show to the user in case no items are found, using any widget (so also a button). Depending on your use case, this might work out better, but please be aware of limitations (e.g. Gallery doesn’t allow multiple filters of the same type for example). 

answered
1

You could use this widget ShowByCondition ( https://marketplace.mendix.com/link/component/2539 ) and but it on the container containing the button. This way you can call a microflow or nanoflow that checks for empty and if so shows the button.

Regards,

Ronald

 

answered
1

Hi Marc,

 

Open the page by a microflow. In this microflow you create a Non persistant object with a boolean attribute (hasRecords). Determine in the mf if the listview you want to show is empty or not and set the boolean based on the outcome. Open the page with the NPE object as page parameter. With conditional visibility based on your boolean attribute you show the listview (if true) or the button with mf (if false).

 

If you retrieve the listview in the page over association of another entity then you can directly use the association (empty or not) for conditional visibility of the listview and button and you don't need the NPE with helper boolean.

 

Regards,

Roel

answered
0

Hi guys, thanks for the quick feedback.

What I forgot to write. 
I would like to have a solution without microflow, because there are a lot of lists displayed on the page (see screenshot, each button represents a list) and I would have concerns about the performance when calling up the page if a microflow is triggered for each list.

 

answered