Friday, July 9, 2010

How to Hide View All Site content & Recycle Bin Links in SharePoint 2010/2007?

Another frequently asked question: How to Hide the Recycle Bin & View all Site content links in SharePoint site? Yes, we can hide them, not a big deal!
How to hide View All site content, Recycle Bin Links in SharePoint

Here is How We Hide View all site content & Recycle Bin Links from Quick Launch in MOSS 2007: Just add the Content Editor Web part and place the below CSS codes ( Add it in Master page if you want to apply for all sites) :
<style>

.ms-quicklaunchheader{display: none;}

.ms-recyclebin{display: none;}

</style>

Hide View all site content & Recycle Bin Links in SharePoint 2010:
 CSS classes are little different
/*To Hide both */
.s4-specialNavLinkList
{
display:none;
}

/* To Hide Recycle bin */
.s4-rcycl
{
display:none;
}

/* To Hide "All Site Content" */
#ctl00_PlaceHolderLeftNavBar_PlaceHolderQuickLaunchBottom_PlaceHolderQuickLaunchBottomV4_idNavLinkViewAllV4
{
display:none;
}

In Action:
Hide view all site content & Recycle Bin from SharePoint
Want to Hide View All Site Content / Recycle Bin Links from everyone, except Site Owners?
Yes, You can set the permission string of these links to hide it from all users except the specified in PermissionString property. 

Open your master page in SharePoint designer (either MOSS 2007 or SharePoint 2010). 
In Design view select "All Site content Link" in Tag Properties, Go to PermissionString and Enter the permission string. Say, you want this link to be available only to Site owners, then enter: "FullMask"
Hide Recycle Bin & View all site content from quick launch
You can use: SPSecurityTrimmedControl also to hide All Site Content or Recycle Bin Links from anonymous user. 

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


SharePoint Site templates, Site Definitions, Feature Stapling - Explained

The main objective of the feature stapling concept is: Pre-activate desired features automatically on creating SharePoint sites based on site definitions like Team Sites (not site template .stp).

say for e.g. you want to apply branding on creating a team sites, You can use feature stapling.

So, In your feature you have to handle the events such as "FeatureActivated" in order to run some code automatically on creating sites. In other words place the code that should get executed inside the "featureactivated" section in your event receivers.

SharePoint Site templates, site definitions, feature stapling Check out my Presentation:


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


KPI Dashboard using SharePoint List

We can generate the KPI list using simple SharePoint list with computed columns! Here is how we can get SharePoint list based status indicator

KPI Dashboard using SharePoint List
Create a SharePoint list with desired fields, then create a field with choices, Lets say, Field name Cost_Input: with values Red, Green, Blue. Then lets create another computed field called Cost of type: Number, which is based on the existing field COST_Input field.

Enter the formula for the calculated field as:

=IF(Cost_input="Green","<DIV style='text-align: center'><IMG src='/_layouts/images/KPIDefault-0.gif'
/></DIV>",IF(Cost_input="Yellow","<DIV style='text-align: center'><IMG src='/_layouts/images/KPIDefault-1.gif'
/></DIV>",IF(Cost_input="Red","<DIV style='text-align: center'><IMG src='/_layouts/images/KPIDefault-2.gif'
/></DIV>")))



Then after add content editor webpart exactly after the list webpart, then add the below code snippet in the source editor of content editor webpart


<script type="text/javascript">
//
// Text to HTML
//
var theTDs = document.getElementsByTagName("TD");
var i=0;
var TDContent = " ";
while (i < theTDs.length) {
try {
TDContent = theTDs[i].innerText || theTDs[i].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTDs[i].innerHTML = TDContent;
}
}
catch(err){}
i=i+1;
}
//
// ExpGroupRenderData overwrites the default SharePoint function
// This part is needed for collapsed groupings
//
function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
var tbody=document.getElementById("tbod"+groupName+"_");
var wrapDiv=document.createElement("DIV");
wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+ groupName+"_\" isLoaded=\""+isLoaded+ "\">"+htmlToRender+"</TBODY></TABLE>";
var theTBODYTDs = wrapDiv.getElementsByTagName("TD"); var j=0; var TDContent = " ";
while (j < theTBODYTDs.length) {
try {
TDContent = theTBODYTDs[j].innerText || theTBODYTDs[j].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTBODYTDs[j].innerHTML = TDContent;
}
}
catch(err){}
j=j+1;
}
tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
}
</script>

Update: For SharePoint 2013, Use the below code in Script editor:
 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
 <script type="text/javascript">
     //load jQuery
     google.load("jquery", "1.2.6");
 </script>
 <script type="text/javascript">
 //make a fn for reuse
 $.calcHTML = function() {
     //loop through TDs moving text node to html
     $("td.ms-vb2,td[id$='Calculated'],td.ms-stylebody,td.ms-formbody").filter(":contains(<DIV)").each(function(){
         $(this).html($(this).text());
     });
 };
 //call calcHTML on DOM ready for ungrouped rows
 $(function() {
     $.calcHTML();
     if (showpreview1) { //check for preview script
         $("td.ms-vb-title").bind("mouseover", function(){
             showpreview1(this);
             $.calcHTML();
         });
     }
 });
 //replace ExpGroupRenderData, call calcHTML for grouped rows
 function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {
     $("#tbod"+groupName+"_").attr("isloaded",isLoaded).html(htmlToRender).show("fast",$.calcHTML());
 }
 </script>
Thanks to: https://www.nothingbutsharepoint.com/sites/eusp/pages/jquery-for-everyone-html-calculated-column-plugin.aspx

Alternate approach: Using Dataview web part to Design KPI Dashboard

Same thing can be achieved using SharePoint Designer & Dataview webpart. Just convert the existing List view to XSLT Dataview and set the conditional formatting as in below images.
 Set the conditional formatting style:
sharepoint dataview kpi


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Alternate Row Color in SharePoint Dataview Web Part List items

Conditional Formatting? sure, but the problem is: If some of the rows are hidden, then conditional formatting will lose its formatting. So, using Javascript and CSS we can apply alternate styles to SharePoint List items.

Sample screen:
Alternate color in SharePoint dataview List items



Just add a content editor web part, and place the below code.

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("makeAlternateColor()");

function makeAlternateColor() 
{
var table = document.getElementById("Dashboard"); //Get the SharePoint List view's Table id using Firebug or IE Developer Toolbar's help and replace "Dashboard". Otherwise this code wont work!
var rows = table.getElementsByTagName("tr"); 
//manipulate rows
for(i = 0; i < rows.length; i++)
{ 
if(i % 2 == 0)
{
rows[i].className = "even";
}else
{
rows[i].className = "odd";
} 
}
} 
</script>
<style type="text/css">
.odd
{
background-color: white;
}
.even
{
background-color: yellow;
}
</style>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Bar Chart to Show Progress with XSL-CSS Trick

We can generate the simple Bar chart based on Sharepoint list data.

Here is how: Just create a list with desired fields then drop a dataview webpart with the list.

Here is the code to generate bar charts. Place them inside the Dataview webpart in appropriate place.

Bar Chart - Progress in SharePoint with CSS

<td>
<span style="width:{format-number(@Completed, '##.#%')}; background-color:blue;"></span></td><td>
<DIV style="position:relative;"><DIV style="background-color:green; width:{format-number(@Completed,'##.#%')}"></DIV>
<DIV style='position:absolute; top:0px;'><xsl:value-of
select="format-number(@Completed, '##.#%')"/></DIV>
</DIV></td>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Image Tool tips in SharePoint using JQuery

Here is my requirement: when I mouse over a image, i should get a tool tip with screen shot for easy usage.

Here is how I've done this using J-Query:


download the jquery files and upload into a document library, from here:
http://plugins.jquery.com/files/dimensions-1.1.2.zip
http://jquery-very-simple-tooltip.googlecode.com/files/jquery.tooltip_v3.2.2.zip
http://blog.jquery.com/2011/09/01/jquery-1-6-3-released/
optional: http://jquery.bassistance.de/tooltip/demo/screen.css

jQuery Image Tool tip in SharePoint

Paste the below code inside the <asp:Content> </asp:Content> ( you can find this tag, at the end of the page)

<link rel="stylesheet" href="Support/jquery.tooltip.css" />
<link rel="stylesheet" href="Support/screen.css" />
<script src="Support/jquery.js" type="text/javascript"></script>
<script src="Support/jquery.dimensions.js" type="text/javascript"></script>
<script src="Support/jquery.tooltip.js" type="text/javascript"></script>
<script type="text/javascript">

$(function() {
$('#ctl00_PlaceHolderMain_tonus').tooltip({
delay: 0,
showURL: false,
bodyHandler: function() {
return $("<img/>").attr("src", 'http://teamsites.Crescent.com/sites/FTPR/PMD/Support/instructions.gif');
}
});

});
</script>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Creating Four Blokcers in SharePoint with Dataview Web Parts

We can design the Four blocker in SharePoint by combining four Data view web parts. Just set the filters for each of the web parts, typical filter will be QueryString Filter on ProjectID for instance!

Finally, the four blocker will look like below screen:
Four Blokcers in SharePoint with Dataview Web Parts

and the diagrammatic representation goes here. Basically the data is stored on multiple lists and presented as a single page.
Dashboards in SharePoint with Dataview Web Parts


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


How to Get the Query String from the URL and Set the Form field value?

Get the Query String from the URL










 From the Above URL, I need to get the value for the parameter: AccountName

Here is how it got achieved using javascript:

function getEID()
{
loc=window.location.href;
var AccNameIndex=loc.indexOf("accountname");
var TempAccountName=loc.substring(AccNameIndex+12);
var AmpLoc=loc.indexOf("&");

if(AmpLoc==-1)
{
AccountName=TempAccountName;
}
else
{
AccountName=loc.substring(AccNameIndex+12,AmpLoc);
}

i=AccountName.indexOf("\\");

Eid=AccountName.substring(i+1);

alert(Eid);
}

Another Case:

Today,I am running in a situation like: I have to get the value from URL and set that value to SharePoint form's field.


My URL is: http://abc.com/sites/xyz/Lists/Metrics/Edit.aspx?List=3f7f4d96%2D00da%2D46f9%2Dae38%2D5053a9e8b321&ID=319&Source=http%3A%2F%2Fabc.com%2Fsites%2Fxyz%2FOwnerEntry%2Easpx%3FProjectID%3D71

from the above I have to extract ProjectId value and set to SharePoint List Forms value.

Get Query String from the URL and Set the Form field

Here is how I have done that with JavaScript.

After the section: <asp:Content id="Content1" runat="Server"
contentplaceholderid="PlaceHolderMain">

Paste the below code:
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("getQueryParam('ProjectID')");

function getQueryParam(parameter) {
var loc = location.search.substring(1, location.search.length);
var param_value = false;
var params = loc.split("%3F");
for (i=0; i<params.length;i++) 
{
param_name = params[i].substring(0,params[i].indexOf('%3D'));
if (param_name == parameter) 
{
param_value = params[i].substring(params[i].indexOf('%3D')+3)
}
}

if (param_value) 
{
document.getElementById('ctl00_PlaceHolderMain_g_602ee269_6f0c_4cb2_8bb1_740b17695b21_ff2_1_ctl00_ctl00_TextField').focus();

document.getElementById('ctl00_PlaceHolderMain_g_602ee269_6f0c_4cb2_8bb1_740b17695b21_ff1_1_ctl00_ctl00_TextField').blur();

document.getElementById('ctl00_PlaceHolderMain_g_602ee269_6f0c_4cb2_8bb1_740b17695b21_ff1_1_ctl00_ctl00_TextField').innerText 
= param_value;

document.getElementById('ctl00_PlaceHolderMain_g_602ee269_6f0c_4cb2_8bb1_740b17695b21_ff1_1_ctl00_ctl00_TextField').readOnly=-1;

document.getElementById('ctl00_PlaceHolderMain_g_602ee269_6f0c_4cb2_8bb1_740b17695b21_ff1_1_ctl00_ctl00_TextField').className="Read-Only";
}
}
</script>

<style type="text/css">
.Hidden-Element {
display:none;
}
</style>
<style type="text/css">
.Read-Only {
BACKGROUND-COLOR: #f0f5f7
}
</style>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Make Read-Only fields in SharePoint List Forms using Javascript

Here is the code to make SharePoint list fields read-only like below screen:
Make Read-Only fields in SharePoint List Forms using Javascript

Here is the code to Make Read-Only fields in SharePoint List Forms using Javascript:
Open your list form (NewForm.aspx or EditForm.aspx) in SharePoint Designer, Paste the below code after: <asp:Content id="Content1" runat="Server" contentplaceholderid="PlaceHolderMain">

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("makeProjectIdReadOnly()");
function makeProjectIdReadOnly() {
document.getElementById('ctl00_PlaceHolderMain_g_f64398c9_7481_4633_ada6_b227977f9884_ff1_1_ctl00_ctl00_TextField').blur();
document.getElementById('ctl00_PlaceHolderMain_g_f64398c9_7481_4633_ada6_b227977f9884_ff1_1_ctl00_ctl00_TextField').readOnly=-1;

document.getElementById('ctl00_PlaceHolderMain_g_f64398c9_7481_4633_ada6_b227977f9884_ff1_1_ctl00_ctl00_TextField').className="Read-Only";
}
</script>
<style type="text/css">
.Read-Only {
BACKGROUND-COLOR: #f0f5f7
}
</style>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Building Dashboards using Dataview Web Part

Dashboards using Dataview webpart

SharePoint Dashboards with Dataview webpart

So, How to get this dashboard?
Create a list with desired fields, convert that to XSLT Data view web part or drop that list into Dataview web part.

Modify the XSL to get the indicators based on logic:

Such as:
 <!-- Display CPI Value --> <td style="text-align: center; width: 60px;"> <xsl:choose> <xsl:when test="format-number(sum($nodeset/@CPI),'#,##0.00;-#') &lt; 0.91"> <img border="0" src="{$varRedImage}" alt="{sum($nodeset/@CPI)}"/> </xsl:when> <xsl:when test="format-number(sum($nodeset/@CPI),'#,##0.00;-#') &gt; 0.90 and format-number(sum($nodeset/@CPI),'#,##0.00;-#') &lt; 0.96"> <img border="0" src="{$varYellowImage}" alt="{sum($nodeset/@CPI)}" /> </xsl:when> <xsl:when test="format-number(sum($nodeset/@CPI),'#,##0.00;-#') &gt; 0.95"> <img border="0" src="{$varGreenImage}" alt="{sum($nodeset/@CPI)}"/> </xsl:when> </xsl:choose> </td>
<!--Overll Health--> <td style="text-align: center; width: 63px;"> <!-- CPI --> <xsl:variable name="CPI_VALUE"> <xsl:choose> <xsl:when test="format-number(sum($nodeset/@CPI),'#,##0.00;-#') &lt; 0.91">25</xsl:when> <xsl:when test="format-number(sum($nodeset/@CPI),'#,##0.00;-#') &gt; 0.90 and format-number(sum($nodeset/@CPI),'#,##0.00;-#') &lt; 0.96">75</xsl:when> <xsl:when test="format-number(sum($nodeset/@CPI),'#,##0.00;-#') &gt; 0.95">100</xsl:when> </xsl:choose> </xsl:variable> <!-- SPI --> <xsl:variable name="SPI_VALUE"> <xsl:choose> <xsl:when test="format-number(sum($nodeset/@SPI),'#,##0.00;-#') &lt; 0.91">25</xsl:when> <xsl:when test="format-number(sum($nodeset/@SPI),'#,##0.00;-#') &gt; 0.90 and format-number(sum($nodeset/@SPI),'#,##0.00;-#') &lt; 0.96">75</xsl:when> <xsl:when test="format-number(sum($nodeset/@SPI),'#,##0.00;-#') &gt; 0.95">100</xsl:when> </xsl:choose> </xsl:variable> <xsl:variable name="Overall_Avg" select="($CPI_VALUE + $SPI_VALUE) div 2"/> <xsl:choose> <xsl:when test="$Overall_Avg &lt; 50"> <img border="0" src="{$varRedImage}" alt="{$Overall_Avg}" /> </xsl:when> <xsl:when test="$Overall_Avg &gt; 49 and $Overall_Avg &lt; 76"> <img border="0" src="{$varYellowImage}" alt="{$Overall_Avg}" /> </xsl:when> <xsl:when test="$Overall_Avg &gt; 75"> <img border="0" src="{$varGreenImage}" alt="{$Overall_Avg}" /> </xsl:when> </xsl:choose> </td>
Here is the overall flow:


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


SharePoint 2007 Start Date End Date Validation in List forms with JavaScript

SharePoint 2007 Start Date End Date Validation in List forms with JavaScript:
<script language="javascript"> 
function PreSaveAction()
{
var blFlag;
blFlag = true;

var SOSOccDate = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","Date SOS Occurred"); 

var DUEDate = getTagFromIdentifierAndTitle("INPUT","DateTimeFieldDate","Due date"); 

var dtSOSOccDate = new Date(SOSOccDate.value);
var dtDUEDate = new Date(DUEDate.value);
var TodaysDate = new Date();

if(dtSOSOccDate != null)
{
if(dtSOSOccDate > TodaysDate)
{
alert("Date SOS Occured cannot be greater than today's date");
}
}

if(DUEDate.value != "")
{
if(dtDUEDate < dtSOSOccDate)
{ 
alert("The Due date cannot happen earlier than the SOS occurred date"); 
blFlag = false; // Cancel the item save process 
}
}
return blFlag; // OK to proceed with the save item 
}
</script>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Image Slideshow in SharePoint CEWP with Javascript and JQuery

Note: This is a image slider implementation. If  you are looking for Rotating Banner for SharePoint using jQuery, see my post: Rotating Banner for SharePoint using jQuery

Upload the images and add the CEWP, then paste the below Code:

<p><b id='banner'></b></p>
<script>
var newBanner=0;
function runOnLoad(){
var bannerImg = new Array();
var bannerLink = new Array();
  // Enter the names of the images below
  bannerImg[0]="http://SharePoint.Company.com/banner/banner1.jpg";
  bannerLink[0]="http://www.honeywell.com";

  bannerImg[1]="http://SharePoint.Company.com/banner/banner2.jpg";
  bannerLink[1]="http://www.microsoft.com";

  bannerImg[2]="http://SharePoint.Company.com/banner/banner3.jpg";
  bannerLink[2]="http://www.google.com";


var totalBan = bannerImg.length;

  newBanner++;
  if (newBanner == totalBan)
    {
    newBanner = 0;
    }
document.getElementById('banner').innerHTML="<a target=_blank href="+bannerLink[newBanner]+"><img height=100 width=200 src="+bannerImg[newBanner]+"></a>";
 setTimeout("runOnLoad()", 2*1000);
}
_spBodyOnLoadFunctionNames.push("runOnLoad");
 </script>

Using JQuery:
Another nice way to get the nice rotating banner is to use: JQuery. Here is how:
1. Upload the images to your site

2. Add the content editor web part

3. you can either upload the JQuery script files to your SharePoint site or point it to Google.
Download URLs:
http://code.jquery.com/jquery-1.7.1.min.js
http://malsup.github.com/jquery.cycle.lite.js

4. Place the following code:

<style type="text/css">
.slideshow { height: 60px; width: 225px; margin: auto }
.slideshow img { padding: 2px; border: 1px solid #ccc; background-color: #eee; }
</style>
<!-- include jQuery library -->
<script type="text/javascript" src="jquery.min.js"></script>
<!-- include Cycle plugin -->
<script type="text/javascript" src="jquery.cycle.lite.min.js"></script>
<!--  initialize the slideshow when the DOM is ready -->
<script type="text/javascript">
$(document).ready(function() {
    $('.slideshow').cycle({
  fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
 });
});
</script>
<body>
 <div class="slideshow">
  <img src="1.jpg" width="225" height="53" />
  <img src="2.jpg" width="225" height="53" />
  <img src="3.jpg" width="225" height="53" />
 </div>
</body>


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


You might also like:

Related Posts Plugin for WordPress, Blogger...