logo

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?

Image

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:

Image


Feedback

    • avatar
    • Johan Känngård
    • Wed 22 Nov 2000

    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.

      • avatar
      • Scot Haberman
      • Wed 7 Mar 2001

      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.

      Show the rest of this thread

    1. 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

    2. 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.

      Show the rest of this thread

    3. 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?...

    • avatar
    • Sylvain Goutouly
    • Mon 26 Mar 2001

    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

    1. 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

      Hide the rest of this thread

        • avatar
        • Sylvain Goutouly
        • Tue 27 Mar 2001

        Re: Not sure I understand...

        I put a font color tag before the $$Viewbody field, for example, if my background color is white, I put <font color=white> before the $$viewbody. You can achieve the same with a div tag and a css. When there are documents, domino generate a html table so the tag is not used.

        But you are right, the user doesn't see "No documents found" or other message anymore. In my experience, the "No documents found" appears only in a very new database in which there are few documents, so the probability for a user to see it is very small ... If there are views which often doesn't have documents I use a hide when formula because the view contains few documents (workflow).

        My latest tips is the same as Scot Haberman with a javascript onload function counting the number of links. What is more, with this method I show/hide the next/previous buttons too.

        1. TotalHits useful, however..

          I must say, that the information i found here is excellent. The reason why i want to "control" the 'no document' message, is because i need this in different languages. So I used the "totalhits=0" or totalhits != 0 to display the message which is a shared field attached to a profile document. However, although this works , i keep getting the standard no document message also.

          My question:

          Is there an option not to display the "No documents Found" message or how can i only "mask" this message, because I now use a style sheet to mask the color to the background, but this means I cannot use H2 tags in my document. I use Domino 5.06

          Is there a special position where this standard message is generated, because then i only need to add the font tag in front of this special "field" or "position" on the form

          Finally, is there a way to control the "position" of the "standard" no documents found message.

          Hope someone knows an answer.

          Thanks in advance Any ideas?

          1. Re: TotalHits useful, however..

            The position of the "No Documents" message should depend on where you have put he $$ViewBody field or the Embedded View element. If you surround this with <div> tags you can control its visibility and hence hide the message

            Jake

            1. Another variation - hiding the initial flash!

              This is a small tweak on what has gone before - so apologies if it has been done this way and I missed it.

              I noticed that the dreaded "No documents found" message still appeared very briefly, so my colleague Rob Latta came up with the lines necessary to hide it until the code had caught up.

              In the HTML just before the Embedded view

              <!-->the line below will hide the result initially in case the "No documents found" message appears</--> <div id="view" style="visibility:hidden"> <table width=100% border = 0 cellspacing=2 cellpadding=2 >

              Your embedded view is here

              </table> </div>

              in the JS Header of your form that the Embedded view resides in, place this code

              function checkDocs(){ var v = document.getElementById('view'); // the line below unhides the HTML code just before the Embedded view that // is in the line '<div id="view" style="visibility:hidden">' v.style.visibility='visible'; if(v){ var pos=v.innerHTML.toLowerCase(). indexOf("<h2>no documents found</h2>") // You can change the text in the line below to suit your requirements if (pos>=0){ v.innerHTML = '<h4>There are no documents to view</h4>'; } } // This is an alternative location for the ''reveal' code // v.style.visibility='visible'; }

              in the 'onLoad' event of the same form

              checkDocs()

              Jake - thanks for all the work that has gone into this site - by you and those who tweak the contents even further - it has been a great help to me in the past few months.

        2. Another method (using javascript DOM)

          Just found this site today... what a fantastic resource!

          Here is a method to replace the 'No documents found' message with any HTML you want.

          Put the following function in your JS header and run it OnLoad

          function CheckNoDocuments() { // function to replace the 'No documents found' message if (document.getElementById("view").innerHTML.indexOf("No documents found") > 0) { document.getElementById("view").innerHTML = "--Put your own HTML here--" } // end if } // end function

          Then all you need is a div or span tag enclosing the view: <div ID="view"> --insert your embeded view here-- </div>

          I have only tested this on IE5.5 and NN6 hope this helps.

          Andy B ;-)

          P.S keep up the good work CodeStore.

            • avatar
            • Jake
            • Fri 17 Aug 2001

            Re: Another method (using javascript DOM)

            Thanks Andy. Glad you like the site ;)

            Thanks for the script to. Nice and simple the way I like it. It will indeed only work with the latest browsers because you have used .getElementById method which is a part of the W3C's DOM 2 spec which only IE5.5 and NN6 have started to implement...

            Jake -CodeStore

            1. Re: Another method (using javascript DOM)

              Just checked it works in ie 5.0 to;

              Here is my code; it runs in the Onload event; In the stylesheet i set the divEmbeddedView to invisible so that when it loads it doesn't show for a second. Only after the Onload i make it appear. The view is surrounded by: <DIV ID="divEmbeddedView"> VIEW </DIV>

              function CheckNoDocuments() // function to replace the 'No documents found' message {

              if ( document.getElementById("divEmbeddedView").innerHTML.indexOf("No documents found") > 0) { document.getElementById("divEmbeddedView").innerHTML = "<BR><CENTER>Place your message here</CENTER>" } ; document.getElementById("divEmbeddedView").style.display="inline";

              }

              An alternative would be to use window.document.all.divEmbeddedView.style.display instead of the getElementByID property

            • avatar
            • H Ray
            • Fri 23 Jul 2004

            Re: Another method (using javascript DOM)

            I have given up on being able to customize No Documents Found message, cause my search template does not support Hits or TotalHits field.

            This solution is simply great.

            Thanks!!

            • avatar
            • Tom
            • Wed 15 Sep 2004

            Re: Another method (using javascript DOM)

            Very cool ! I like this solution a lot.

    • avatar
    • EQE
    • Thu 12 Dec 2002

    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'; }

    }

    • avatar
    • Keven Robidoux
    • Thu 2 Oct 2003

    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...

    • avatar
    • Espe
    • Mon 13 Oct 2003

    Great

    So easy it can be sometimes, that was a great way to hide that message

  1. 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"; }

      • avatar
      • cap
      • Wed 8 Jun 2005

      Supper, thanks!

      I find this method the be the easiest and most reliable to implement.. thanks for posting the tip.

    1. 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"; }

  2. 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?

    • avatar
    • Chris C
    • Wed 9 Oct 2013

    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.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Views"

« Previous Article Next Article »
Display Rich Text fields in a view   URL Syntax for advanced field level searching

About This Article

Author: Jake Howlett
Category: Views
Keywords: CSS; Style;

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »