In a previous JS Link / CSR post we covered how to handle what is displayed in a web part when there are no items to show. SharePoint’s default message is an ambiguous:
“There are no items to show in this view of the [listname] list”
Not an awesome user experience. Something a little more contextually relevant might be more helpful to users – either in a simple list view, or in a more complicated solution.
A PowerApps Gallery control isn’t any better – merely showing a blank record. The Data Table control, on the other hand, has a handy ‘NoDataText’ property that can be configured to display a message when the control is empty.
So, what do we do when using Gallery controls – until a ‘NoDataText’ property is added and/or the Data Table control allows for more configuration options? As is the answer with many things in PowerApps: We use a formula.
Using an appropriate text field control within a Gallery control, we can replace the Text property with a formula like the following:
If(CountRows([_List Name_])=0,”[_Put your message here_]”, ThisItem.Title)
For a SharePoint list named: DefaultList you get the following:
If(CountRows(DefaultList)=0,”Nothing to see here”, ThisItem.Title)
The ‘CountRows’ function as you might guess returns the number of rows in the list.
The ‘If’ function tells the control to set the displayed value of the control to “Nothing to see here” if the condition (there are 0 rows) evaluates to ‘true’. If not, the value of the control is ThisItem.Title – the normal field value we would expect in the control. The text is only displayed when there are no items in the list.
- Get started with formulas – PowerApps
- CountRows reference in PowerApps
- If function in PowerApps
- Data table control in PowerApps
- Gallery control in PowerApps
- JS Link – No items to show blog post
We met at the SP Conference 2017 in Chicago. I have only attended the last 2 conferences, and always feel like I have learned something from your presentation! Thank you. However, I am still new to SharePoint Online, starting to build our Intranet. I used SP Designer before with SP10, but now it is built into SP Online and it’s not quite the same. I do not know how to get to the ASP code, how to download the pages to modify them. Is there another software we could use to do more of the development and programming to customize pages? I have not been lucky at finding what I need and how to set up a development environment to customize the web code. Could you please steer me in the right direction? Thanks!