The default message displayed in a view when that view has no items to display is:
“There are no items to show in this view of the [listname] list”.
In most cases this is just fine. When users are working directly in a list this message is consistent with the user experience.
If for whatever reason this text needs to be overridden there isn’t an obvious or simple approach to do this through the UI.
The default text is set within each list behind the scenes. If you were to change the property of the list directly using some custom approaches it would change the message for the list and be seen in all views. Using CSR, we’re going to change what is displayed without changing the core data. This give a few advantages:
- We generally don’t want to make permanent customizations if we don’t have to.
- Using CSR we can update the message for *each* view as necessary – which might be more appropriate for each use case.
The bonus here is that it’s REALLY easy using CSR once you’ve figured it out.
So, here’s how it works:
Note: Normally I don’t add CSR to actual view pages – *especially* the All Items view – but technically you can. I generally use a separate page with a web/app part dropped on the page and apply CSR using JS Link at that point. But for this simple example we use the straight-up view page.
Our view starts out like this:
Now, you can take a shortcut by using the Footer override, but this will override both the default message when there are no items in the list *and* be displayed when there are items displayed. Fine if the override is blank, but not useful if you’re actually displaying a message.
overrideCtx.Templates.Footer = “ “;
Applying this code as JS Link file gives us the following:
Pretty slick now that we’ve figured it out.
Thanks again to Raymond Mitchel (@iwkid) for helping with digging through the background details.