If you want to use this type of datagrid, you need to specify a helper object that can keep track of the object count. Create a dataview that includes that count in an attribute. Put the datagrid within that dataview and use visible conditions to show the datagrid based on the expression:
$dataviewHelperObject/CountObjects > 0
Consider upgrading to Datagrid 2. It has empty state functionality out-of-the-box. You can find it in the data widgets module.
If you are looking to prettify you page, consider using the badge of the tab to show the number of objects.
Where test is the attribute Ruud suggested to create
If you are using a mendix version where data grid 2 is not yet available, then you could use the following work around:
- Place a list view under the data grid with the same data source.
- Do not fill the list view with anything.
- In the properties set the page size to the largest number possible (1000) to hide the ‘Load more’ button.
- Set in appearance of the list view the Style: No styling, Row size: small, and in Style: height: 20px;. See this screenshot as example.
Resulting in the following setup on the page in the Structure mode:
The list view shows a message when empty, but does not show anything at all if there are records. This way it provides a empty message for the data grid. As a user it is not visible that it is a different widget. See for yourself: