SharePoint 2010 – Hiding the Search Bar

Have you ever needed to hide the search bar on your site?  Me neither until the other day.  The page needed to be plain Jane and this was one of the requests.  Turns out, this is very simple to do.  All that you need to do is add a Content Editor Web Part (CEWP) to your page and add the following lines of code to it:

This code will hide both the search bar and the search icon.  It’s that simple!  Try it for yourself.

Stay Salty!

jQuery Security….. Just hide it!

We had an issue come up about security with InfoPath forms.  One of the major issues was that we could restrict items in the view, but if you used explorer view, all of the security would be bypassed.  To counter this, we use a CEWP and the following jQuery script: HideViewsScript

Please note, you will need to change the first line in the script to reference your jQuery file:

<script src=”/PublishingImages/javascript/jquery-1.3.2.min.js” type=”text/javascript”></script>

This will disable all of those pesky views and you will be able to force your security through your main view.

Add a time duration to a list/library

Years ago, I setup an InfoPath form for an approval process.  There are around 7 status changes during the duration of this form.  We wanted to be able to see how long a request would take from creation to approval.  This was actually pretty simple.  All that you need is a calculated column.  Follow these steps and you will be able to time an event/process.

  1. Open list/library.
  2. Create Calculated Column (Form Duration)
  3. Enter this for the formula:  =TEXT(Modified-Created,”h:mm”)
  4. Click OK

That’s it!  The calculation will look at the fields provided in the formula.  The time will then calculate based on how long it took from creation to when it was last modified.  If you have a form that hides a submit button based on a status, you will then be able to lock down the time calculation.

Enjoy!

Adjust Width of SharePoint Columns

SharePoint lists and libraries are great.  However, you may have noticed that sometimes, the column width on certain items just looks funky.  To remedy this, all you need to do is add a little javascript.

Go to the list or library that you want to resize and add a Content Editor Web Part.

From the script below, I am referencing jQuery from my internal site.

Copy and paste this code into the CEWP.

<script src=”/PublishingImages/javascript/jquery-1.3.2.min.js” type=”text/javascript”></script><script type=”text/javascript”>$(function(){$(“TH.ms-vh2-nograd:contains(‘Column 1’)”).css(“width”, “350px”);

$(“TH.ms-vh2-nograd:contains(‘Column 2’)”).css(“width”, “350px”);

});

</script>

Column 1” and “Column 2” will be the name or your columns that you want to resize.

Here is an example I used and only resized one column:

Before:

 

 

 

__________________________________________________

After:

 

Create an A-Z quick filter web part

If you have a list, like a corporate phone directory, you may start thinking “Man, I wish I could sort through these by the first letter of their name”.  If you weren’t thinking that, it’s ok.  I was so that why I decided to post this.  Follow these steps and your new web part will be up and running in no time.

  1. Open the list that you want to add the A-Z filter to (my case “Employee_Phonebook”)
  2. From the “Employee_Phonebook” tool bar, click “Settings –> Create Column”
  3. Name the column “A-Z” or whatever name you would prefer
  4. Select “Calculated” as column type
  5. Under Additional Column Settings, select “Title” from Insert Column and type =LEFT([Title],1) into Formula. Keep all default settings and click “OK”.  Note: “Title” is the name of the column you are targeting for this list (i.e. Last Name)
  6. You will see new column called “A-Z” and has the letter “A” value in them already.
  7. From the Site Actions tab, click Edit Page
  8. Click Add a Web Part and add the “Content Editor Web Part”
  9. Modify that Content Editor Web Part and click the “Source Editor” button to add the following code.
    ** Note: You will need to modify the URL’s below to reference your site.

 

  1. Click “Add a Web Part” and add “Query String (URL) Filter”
  2. Enter a name for “Filter Name” then enter “FilterBook” into “Query String Parameter Name” then click “OK”
  3. Now from Query String (URL) Filter, select Edit –> Connections –> Send Filter Values to “Employee_Phonebook” and when the Popup appears select “A-Z”
  4. Click the Finish button and your done

Your finished product will look similar to the image below