Beter Empty listview, datagrids options - Mendix Forum

Beter Empty listview, datagrids options

14

currently, we want to hide the title and listview if it is empty.

We do this with jquery which isnt really a nice option.

I would really like some conditional visability with a listen on the listview so if can hide itself or generate a different messege depending on the context.

Solutions like this dont work well and are not very scalable:

$(document).ready(function() {
 
setTimeout(function(){
$(".mx-listview-empty").closest(".ap_hideifempty").addClass("displaynone")
}, 1000);

});

 

or


asked
4 answers

At this moment i would suggest you to just model it in Mendix.

Create a Datasource microflow wich retrieves the first object according the same XPath you use in your listview. let that microflow return that 1 object that is found (if none is found empty will be returned). Make sure to retrieve only the First object since you want to show the title and listview if 1 or more objects are found.

In your page surround the listview and the title with a dataview of the same object, wich uses the datasource microflow you just created.

Set conditional visibility of that dataview to:

$currentObject != empty

That way everything in your dataview will be only shown when the retrieve action in the microflow returns an object, and if no object was found, everything in the datagrid will not be shown.

Created

Hi Jason, did you ever find a better solution for hiding the list and title/surrounding container, or are you still stuck using jQuery?

Created

not if you want custom text or want to hide the title or other elements based off of if the list is empty or not

Created

Is the class .mx-listview-empty not sufficient?

Created