Hide a list webpart in page Sharepoint if the list is empty in Pages

Copper Contributor

Hi,

We have a list is empty or only contains a single record with an important message for show in Home page. if the list has not a record I want to hide the list web part, any ideas how this can be achieved or any other solution that might be interesting?

My only solution is: I use a component list, but even if it is empty, it takes up space on home page that is not reduced, and the next component is more down.

Thanks.
Regards,
David.

2 Replies

Hello @Davidllem 

 

this settings is not available on list or document web part.

 

Other ways:

- Use the list with a View Formatting (as example: https://adoption.microsoft.com/en-us/sample-solution-gallery/sample/pnp-list-formatting-announcement... )

- Use an highlighted content webpart, in there you have the setting "Hide this web part if there's nothing to show"

- Or use PnP Modern Search Results Web Part also with the setting "Hide this web part if there's nothing to show" (https://microsoft-search.github.io/pnp-modern-search/ )

 

I think in your case the first entry can help you, it's easy to implement.

 

Best, Dave

@David Mehr Can you add the code here that hides the List Webpart if it is empty using Json?  I'm having a hard time finding it in the example you added.  (https://adoption.microsoft.com/en-us/sample-solution-gallery/sample/pnp-list-formatting-announcement...

Thanks!