Control the look of the "No documents found" message
Are you fed up with having made your site look really nice only to be shocked when you open a view and the, ugly looking, "No documents found" message stares back at you?
Now, assuming you are using templates to display your views ($$ViewTemplate for name), you can apply a stylesheet to over-ride the above.
Domino uses the <h2> tag to display the above message, so all you need do is redefine this using CSS. Do this by placing something like the following in to the header of your form (or place it inside the .css file that you include):
<style type="text/css">
<!--
H2 {
color : #FFFFFF;
font : normal 10pt Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
The message will then appear a little more pleasing to the eye, as below:
Even better solution
If you don´t want any error message at all, us a Hide-when formula to hide the embedded view with the formula: @Elements(@DbColumn("":"NoCache";@DbName;YOUR_VIEW;1) = 0
Even better, this is great if you want a customized error message. Put the message on a separate line and hide it with the formula:
@Elements(@DbColumn("":"NoCache";@DbName;YOUR_VIEW;1) != 0
The @DbColumn can be done in a field instead, to reduce the number of @DbLookups that should be performed when opening the form.
Reply
Re: Watch out for performance
When you start getting a lot of documents, this will slow down the entire process. We found that with 75,000 documents, it would take almost 20 seconds to load each page.
Another alternative is to use the display attribute of CSS. We wrap this style around the view and have another line containing the string to display if no docs are found (again with the style wrapped around it). both are hidden to start. Then using JavaScript, we search the view for the string No documents found. If it is there, we un-hide the message otherwise we un-hide the view.
Reply
Show the rest of this thread
Hide the message using Totalhits field
I used the same solution but using this formula:
REM "Si la búsqueda no es nula/If the search result is null "; TotalHits=0
Remember put the Totalhits filed in the form
Reply
Another reason why I prefer this method
I also use this method, because it enables me to add a line of contextual user-friendly text, e.g.
"There are no product reports in this section."
or
"There are no contacts listed yet."
Naturally the Hide-When formula in this instance is the exact opposite of the one used to hide the system-generated message.
Reply
Show the rest of this thread
Re: Even better solution
But how do you make this work w/ single category views? It will look up and see that the view is not empty but the category the user is looking at might be?...
Reply
Using font tag instead
I just use a <font color> tag to put the same font color as the background color to hide the No document found message
Reply
Not sure I understand...
I can see what you mean but I don't think it is obvious to us all how exactly you achieve this. i.e. where do you put this font tag and when do you hide it etc.
Also, I have to say that I think the "No documents" message does serve a purpose, in that it presents a message to the user without which they may be left confused.
Jake -CodeStore
Reply
Show the rest of this thread
another method using DHTML
how about the following:
//styles #viewbody{ border-bottom-width: 1px; border-color: #191970; border-left-width: 1px; border-right-width: 1px; border-style: solid; border-top-width: 1px; height: 25px; }
#emptyView { height: 25px; text-align:center; width: 75%; top: 15%; margin-top: 15px; }
//html <div id = "viewBody">$$viewBody field goes here </div> <div id = "emptyView"> no documents have been found at all</div>
//javascript
function checkEmpty() // function to replace the 'No documents found' message { if (document.getElementById("viewBody").innerHTML.indexOf("No documents found") > 0) { document.getElementById("viewBody").style.display = 'none'; document.getElementById("emptyView").style.display = 'inline'; } else { document.getElementById("viewBody").style.display = 'inline'; document.getElementById("emptyView").style.display = 'none'; }
}
Reply
another method using javascript (and old browser)
1- You have to hide the "no document found" (see above how).
2- Add an hidden colomn to your view generating an hidden "href=nowhere".
3- On the onload of your <Body>, look at every links of your page to find an href="nowhere" (or the twisties in case your view is in collapsed mode).
for (var i=0;i<document.links.length;i++) { if document.links[i].href="nowhere" ...
4- If no links are found then display your message with document.write("Aucun document trouvé")
working fine with every browser...
Reply
Great
So easy it can be sometimes, that was a great way to hide that message
Reply
A Dynamic Find and Replace
After reviewing all posts here, I found yet another method which is preferrable for my application. I use category view queries like this... productview.dsp?OpenForm&Products=ABRAS:Con ... that can return "No Documents Found." The view has documents, just not with the category, so I cannot depend on a row count in the view.
This method effectively does a find and replace on the text "No Documents Found" on the fly.
Thanks to Fernando Matias Valadao who posted this on http://searchdomino.techtarget.com.
1) In the "HTML Head Content" of your form or page, add this code: "<style> H2 {display:none;} </style>"
This momentarily hides any H2 text, including the No Documents Found message.
2) Add this code to the "On Load" event of your form or page. It searches all H2 text and replaces the No Document Found text. It then displays all H2 text.
var noDocumentsFound = document.body.all.tags("H2"); var tagH2, textH2;
for (var i = 0; i < noDocumentsFound.length; i++){ tagH2 = noDocumentsFound[i]; textH2 = tagH2.innerText; if (textH2.toLowerCase() == "no documents found"){ tagH2.innerHTML = '<BR><FONT SIZE=2 FACE="Arial" Color =#00673>Nothing found. Please search again.</FONT>'; } tagH2.style.display = "block"; }
Reply
Supper, thanks!
I find this method the be the easiest and most reliable to implement.. thanks for posting the tip.
Reply
Small change, but well get it working i firefox...
Small change, but well get it working i firefox...
var noDocumentsFound; var tagH2, textH2;
if (document.getElementsByTagName) { noDocumentsFound = document.getElementsByTagName("H2"); } else if (document.body.all){ noDocumentsFound = document.body.all.tags("H2"); } for (var i = 0; i < noDocumentsFound.length; i++){ tagH2 = noDocumentsFound[i]; if (document.getElementsByTagName) { textH2 = tagH2.innerHTML; } else if (document.body.all){ textH2 = tagH2.innerText; } if (textH2.toLowerCase() == "no documents found"){ tagH2.innerHTML = '<BR><FONT SIZE=2 FACE="Arial" Color =#00673>Nothing found. Please search again.</FONT>'; } tagH2.style.display = "block"; }
Reply
no doc's found
I am calling a remote url where documents reside from a report. If the remote document is not found, I get a unfriendly message. Is there any java script function available to display a friendly message when the url fails to retrieve a document?
Reply
This is 13 years too late, but using jquery, you can use the following:
//to remove it:
$('h2:contains("No documents found")').remove();
//to style it like you did:
$('h2:contains("No documents found")').css('color', '#FFFFFF').css('font', 'normal 10pt Verdana, Arial, Helvetica, sans-serif');
This will keep you from screwing up any other H2s on your site.
Reply