Tuesday, May 4, 2010

HOW TO Display Expand/Collapse icons in a SharePoint List

Insert the following code in a Content Editor Web Part to display +/- icons to expand/collapse Items in a SharePoint List. The icons will appear in the Actions Menu in the List.

<script type="text/javascript" src="/../JavaScript%20Library/jquery-1.2.6.min.js"></script>

<script type="text/javascript">

function collapseGroups() {



function expandGroups() {



$(function() {

var expandAll = "<a href='#' onClick="


+'"><img title="expand all groups" style="border:none;" alt="expand all" src="/_layouts/images/collapseplus.gif"></a>';

var collapseAll = "<a href='#' onClick="+'"'


+'"><img title="collapse all groups" style="border:none;" alt="collapse all" src="/_layouts/images/collapseminus.gif"></a>';




HOW TO Display a "Printer Friendly" button on SharePoint pages

Insert the following code in a Content Editor Web Part to display a “Printer Friendly” button on SharePoint pages. When you click the button, it opens the SharePoint page in a new window. And the page will not contain the left and top nav bars. You are also presented with the list of printers that you can print to. And you can also do a Print Preview. This way you get to print only the content that you are really interested in, as opposed to the navigation menus, etc.

NOTE: In the code sample below, the jQuery file was stored in a SharePoint Doc Lib. You can also point to the Google site which hosts the jQuery file like this:



<script type="text/javascript" src="jQuery/jquery-1.3.2.min.js"></script>


<input id="printBtn" type="button" Value="Printer Friendly" alt="Print this page" style="margin-top:10px;margin-left:10px;"/>





var strlink="";



strlink+="<link rel = 'stylesheet' href='"+$(this).attr('href')+"' type='text/css'/>";




var htmlStr ="<html><head>"+strlink+"</head><body>"+$("#MSO_ContentTable").parent().html()+"</body></html>";

var PrintingWindow = window.open("about:blank","","toolbar,width=800,height=600,scrollbars,resizable,menubar");




HOW TO Embed a Video file in a Content Editor Web Part

Insert the following code to embed a video file in a SharePoint Content Editor Web Part. Replace the ref value="" with the path to your video file.

<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer1" width="300" height="235">

<param name="URL" ref value="http://intranet.na.xxxx.com/sites/videos/pages/Profile.aspx?AssetID={1B89321E-E227-4FE5-978A-4D4CEF45FD7D}&DownloadFilePath=%5c%5cKFTUSOKTULAP110%5cTubeTarget1%5c2009%5c40%5c1b89321e-e227-4fe5-978a-4d4cef45fd7d%5cFile.wmv">

<param name="rate" value="1">

<param name="balance" value="0">

<param name="currentPosition" value="1">

<param name="defaultFrame" value=1>

<param name="playCount" value="1">

<param name="autoStart" value="0">

<param name="currentMarker" value="1">

<param name="invokeURLs" value="-1">

<param name="baseURL" value>

<param name="volume" value="50">

<param name="mute" value="0">

<param name="uiMode" value="mini">

<param name="stretchToFit" value="0">

<param name="windowlessVideo" value="0">

<param name="enabled" value="-1">

<param name="enableContextMenu" value="-1">

<param name="fullScreen" value="0">

<param name="SAMIStyle" value>

<param name="SAMILang" value>

<param name="SAMIFilename" value>

<param name="captioningID" value>

<param name="enableErrorDialogs" value="0">