18.09.2011 I have added a bit more functionality. The CEWP code and the file “PreviewMetadata.js” has changed. Re-read this article for details.
This is a remake of a previously posted solution for previewing an item in a list when hovering over the table row or a custom image. You find the code below, but first an overview of the features.
This solution works in both SharePoint 2007 and in SharePoint 2010, but the code is different for the two. It is tested in plain list (and document library) views with grouping and paging, and in calendar views. You can specify which columns to preview, or have the full DispForm array of fields. If you have multiple list view web parts in one page, you can specify which lists to activate this feature on.
Download the code for the file “PreviewMetadata.js” from here. Ensure you pick the right version (SP2007 or SP2010). Upload the file to a shared document library, or put it in a folder using SharePoint Designer. You then insert a ContentEditorWebPart (CEWP) below the list view web parts in the page. You must modify the script src to the file “PreviewMetadata.js”, and if you like, to the jQuery library.
Read here how to find the list Guid and the FieldInternalName for your list fields.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="/test/English/Javascript/PreviewListItems/PreviewMetadata.js"></script>
<script type="text/javascript">
config = {arrOfFieldsToShow:[],
hideIdColumn:true,
activeListGuids:[],
hideCreatedAndModified:true,
hideFormLabel:false,
hoverDelay:100,
hoverImg:{active:true,
path:'/_layouts/images/chm16.gif',
height:'12',
width:'12',
prependTo:'LinkTitle',
hoverImgDescription:'Hover over this image in the list to preview the list item'}};
initjLoadMe(config);
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="/test/EMSKJS/PreviewMetadata/PreviewMetadata.js"></script>
<script type="text/javascript">
config = {arrOfFieldsToShow:[],
hideIdColumn:true,
activeListGuids:[],
hideCreatedAndModified:true,
hideFormLabel:false,
hoverDelay:100,
hoverImg:{active:true,
path:'/_layouts/images/chm16.gif',
height:'12',
width:'12',
prependTo:'LinkTitle',
hoverImgDescription:'Hover over this image in the list to preview the list item',
openInDlg:true}};
initjLoadMe(config);
</script>
Note to SharePoint 2010 users:
Add this code to a text file and put it in a document library, then use the content link option on the CEWP to link to this code. This is necessary to overcome a possible “bug” in the CEWP handling when editing a SP2010 page where the HTML is accumulated when editing the page.
This tip is also recommended for SharePoint 2007 users, but is not absolutely necessary.
- arrOfFieldsToShow: Array of FieldInternalNames to show. Leave empty to show all fields from DispForm. (*) To hide the field name for individual fields in the preview, put # as a suffix to the name like this: ['Title#'].
- hideIdColumn: true or false. If true, the ID column must be placed to the far right in the view.
- activeListGuids: Array of the Guids of the lists to activate this feature in. If left empty, all list view web parts will be active. Use this if you have more than one list view web part in the page and does not want to activate this feature for all web parts.
- hoverImg: If the parameter “active” is true, the preview will be shown when the user hovers over the image specified. If false, the preview will be shown when the user hovers over the table row.
- hideCreatedAndModified (*): true or false. Determines whether or not to show the “Creates by” and “Modified by” at the bottom of the preview.
- hideFormLabel (*): true or false. Determines whether or not to hide the field names column entirely. When set to true, this one overrides individual field settings under “arrOfFieldsToShow”
- hoverDelay (*): The delay in milliseconds from the user hovers over the image / row until the preview is triggered. If used with “hover” over the entire row, set this higher to prevent shoving all previews when the user swipes the mouse over multiple rows.
- active: true or false.
- path: The path to the image used as “hover image”.
- height: Image height in pixels.
- width: Image width in pixels.
- prependTo: The FieldInternalName of the field to prepend the hover image to. The Title field with menu has FieldInternalName “LinkTitle”
- hoverImgDescription: The Description text on the “instructions” shown above the list view.
- openInDlg: (SharePoint 2010 only) Defines whether the form is opened in a dialog when the user clicks the hover image.
(*) New in v2.3 for SharePoint 2007 and v1.1 for SharePoint 2010.
Ask if something is unclear.
Alexander


December 14, 2011 at 11:17 pm |
Hello Alexander,
Thank You very much for your work. I really appreciate it. I am using sp2010 and downloaded latest feature. I have a question, can we make a hover work for a specific column rather than in title column.
For example
I have
Program, program status, program comments, Page, Page status, page comments.
Columns in a sharepoint custom list. So when i hover over Program or a Page, i want it to popup items in program status and program comments in context of program. But when i hover over Page can i pop up page status and page copmments in a box.
Is thsi functionality possible with our solution. If yes can you provide me place where i need to make adjustments.
Thank You
December 14, 2011 at 11:56 pm
Hi,
This is not possible as the solution lets you have only one “hover action” in each row.
Alexander
December 16, 2011 at 4:04 pm |
Alexander
I have sent the screen shots and CEWP code to your email id. Thanks again for your assistance!
AP
December 19, 2011 at 5:17 am |
Hi, did you get a chance to diagnose what AP posted? I am having the exact same issue in SP2010 Enterprise calendar view. Just getting the blank hover bar. Tried everything listed here with no content showing.
December 30, 2011 at 10:27 am
Hi,
Yes, AP found that it was an error occurring when more than 5 items was listed in one day. I have not had the time to verify it yet, but it’s on the “stuff to do” list.
Alexander
January 6, 2012 at 12:59 am
Hi,
I was mistaking regarding the cause of the “blank popup error”. Could you help us shed some light upon the reasons for this behavior?
I have not been successful in recreating this bug.
Alexander
January 6, 2012 at 2:12 am
I have a single calendar with 9 overlays and 25 views (not that this should matter). There is a lot of content displayed at once which works great however this overlay would really help. I have the calendar embedded as a web part on a page. Right beside it I have a hidden CEWP which points to the 2010 CEWP code in a text file using the Content Link. That text file and the .js file are saved in a document repository. The text file has an absolute URL pointing to the .js file. When I hover over the calendar entries I get a very thin sliver of the overlay with no content in it. I’ve tried putting individual field names in the arrOfFieldsToShow with no luck. In fact, the sliver of overlay goes away completely when I do that but I could have my syntax wrong. Otherwise I made no changes to the code shown above except the path to the .js file.
Hope this helps. Thanks so much for your advice and hard work!
January 24, 2012 at 5:00 pm
Any thoughts? Still just a blank line on mouseover.
January 28, 2012 at 1:23 am
Sorry, but I have not been able to reproduce the error and without being able to see it “hands on” in a system experiencing this error, there is nothing I can do.
If it were possible or me to log into your site end have a look, I might be able to pinpoint the cause.
Alexander
January 30, 2012 at 8:37 pm
It’s working now. We have heavily customized the master page to not look out of the box. During the process other page templates were customized and we slowly rolled each one back to stock. That’s the only thing I can think of that has resolved it. The only issue now is the delay, it takes a couple seconds or so for the data to appear in the hover.
December 19, 2011 at 9:22 pm |
I am not sure if everyone has had issues with this, but modifying the css of the jLoadMe does not actually change anything. That is, changing
.css({‘position’:'absolute’,
‘left’:pX,
‘top’:pY,
‘background-color’:'#fafafa’,
‘border’:’2px solid #C3D940′,
‘padding’:3,
‘width’:contentWidth})
did not actually result in changes.
December 29, 2011 at 6:51 pm |
Thank You for you answer Alexander,
One more question,In arrOfFieldsToShow i want to add column named First Name. How do i add that in to the array field, i looks like it only takes one word.
It is taking Name but it is not taking First Name.
December 30, 2011 at 10:33 am
Hi,
Look here to learn how to find FieldInternalName
Alexander
December 31, 2011 at 12:09 am |
Thank You Alexander,
Question, Is it possible to click on the item inside the pop up box. When you take mouse off the field pop up disappears.
January 3, 2012 at 11:31 pm |
Hey Alex,
Can we idle pop up box for couple of seconds when hovered so that end user can click item inside the box.
January 26, 2012 at 3:20 pm |
Great post, but I’m having trouble downloading the PreviewMetadata.js file… clicking your link just takes me to a “internet explorer cannot display…” blank page. Is there anyplace else I could get the file?
Thanks!
January 26, 2012 at 3:36 pm
Hi,
The link is updated.
Alexander
January 27, 2012 at 12:21 am |
Can I hover over and display a description on (just) one word in the column.
Connie
February 5, 2012 at 9:54 pm
Hi,
No, it’s either the “row” or an image specified as “hoverImg”.
Alexander
February 2, 2012 at 5:30 pm |
Alex,
In a pop-up box, some of the texts are going out of the box. IS there a way to wrap the content inside the pop-up box.
Thank You
February 2, 2012 at 5:40 pm
Which browser are you using? It works for me with no issues on IE8. I did notice that it goes outside the box on Chrome, but then again, SharePoint in general doesn’t work well in Chrome.
February 10, 2012 at 12:11 am
I’m in the process of redoing the solution for SharePoint 2010 – is it SP2010 you are using?
Alexander
February 10, 2012 at 12:33 am
Alex,
Yes I am using SP2010
Thank You
May 16, 2012 at 11:06 pm
Hi Alex, is there a code fix available regarding having the text wrap itself within the preview form text box?
Thanks again!
February 3, 2012 at 8:18 pm |
Nick I am using IE8 but it works fine in Firefox. Is there anything i can do to fix this
Sabin
February 3, 2012 at 9:10 pm
Sorry, I’ve never had that problem in IE8.
February 10, 2012 at 12:32 am |
Alex,
Yes I am using SP2010
Thank You
February 11, 2012 at 3:06 am |
Excellent work as always, Alexander.
I’ve added a parameter to the config – enableListView:false . In our situation we don’t want to see the metadata preview for list views, only calendar views. I’ve also customized the appearance to look somewhat like a post-it note. Works like a charm and our users love it!
Trevor
February 13, 2012 at 3:00 am |
Hi,
How do we make the pop up box wider. Is there something we can change in javascript file?
February 13, 2012 at 9:36 am
SharePoint 2007 or 2010?
Alexander
February 24, 2012 at 9:02 am |
Is there a way to display the content of the pop up in a seperate CEWP instead? I would like to display the content in a fixed place for the user when they hover over a list item and can’t figure out how to achieve that.
Thank you in advance.
Daniel
March 3, 2012 at 11:02 am
The content of the preview is placed in a container with ID “jLoadMe”. Look in the script for this container ID, and insert the ID of the container you want to use in stead. You will have to bypass the part of the script that positions the container “floating”, but this should be fairly simple.
Alexander
March 3, 2012 at 12:25 am |
Maybe someone can help me here. I am working with MOSS 2007 and I have got the previewmetadata scipr working perfectly. Thanks Alexander by the way, excellent stuff as usual. I am using it to display contact numbers for technicians on a site. Problem is when they hover over the line item the number pops up but as soon as they move the mousze it goes away and they need to move the mouse to select their IP phone to make the call. I would like it to pop up onclick, and to go away onclick if at all possible. if so, how do I do this? Any help would be appreciated, I am new to Jquery and javascript so I do apologize for asking such a silly question to most of you.
March 8, 2012 at 9:52 pm
Hi,
This code does not have support for what you ask, but you can play around with this bit of code found various places:
$(“#jLoadMe”).html(”).hide();”
If you comment it out, the preview will not disappear. I’m afraid I cannot promise any updates to this code.
One question though – why not have the phone number visible in the view if this is what the users want to reach?
Alexander
March 11, 2012 at 7:49 am
Thanks Alexander, I will play around some more with this and see what I come up with. This list has hundreds of rows, with multiple visible columns (the phone numbers are not in the view, because it would look to cluttered). All that the popup displays is the phone numbers of both the primary technician and the backup technician, both office and cell numbers.
March 19, 2012 at 10:00 pm |
I dont know if I’m doing something wrong but i just keep getting this skinny textbox with no content in it. I followed the code exactly and even added specific columns. Can I get some help on getting this to work correctly?
config = {arrOfFieldsToShow: ['Title','Location'],
hideIdColumn: true,
activeListGuids:[],
hideCreatedAndModified: true,
hideFormLabel: false,
hoverDelay: 100,
hoverImg:{active:true,
path:’/_layouts/images/chm16.gif’,
height:’12′,
width:’12′,
prependTo:’LinkTitle’,
hoverImgDescription:’Hover over this image in the list to preview the list item’,
openInDlg:true}};
initjLoadMe(config);
May 2, 2012 at 5:16 pm |
Replace this $(“#jLoadMe”).html(”).hide();
with this:
setTimeout(function(){$(“#jLoadMe”).html(”).hide();}, 3000);
to set the time for the Preview popup
May 14, 2012 at 6:37 am |
Hi Alex,
I’am using SharePoint 2010, I can’t to display tooltip with calendar using Custom Form with Infopath (displayifs.aspx), not default Display form. You can help me?
Thanks,
May 16, 2012 at 11:08 am |
Hi Alex, I wonder if your script could me modified to fit my requirements. I need some urgent help to create some ECMA scripts for my project. I have an html map of europe with 39 countries marked out in hotspots. I have a SharePoint 2010 list with 3 fields; country, description, and url.
I want to create an ECMA script to create a pop up with the country name and description when a user hovers over that country on the html map. I will be pasting this code into a Content Editor Web Part for use on my Intranet. I need to retrieve and filter the list data, then bind to the onmouseover event to trigger the pop up with the information.
Can anyone help me with the script, I am new to Javascript. my HTML map code looks like this:
May 16, 2012 at 11:12 am
Read here how to post code in comments
Repost the code and I’ll take a look.
Alexander
May 16, 2012 at 2:25 pm |
Hi Alex, my code looks like this, I have no idea what i am doing!
I can’t find how to put code in here but here is a link to a forum i have posted in:
http://social.msdn.microsoft.com/Forums/en-US/sharepointcustomization/thread/d2fb4423-952b-42a2-beb5-37a42bf2f073