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:

 

Highlight line items in a SharePoint list

This is actually a very simple process and only requires a small amount of javascript to do the job.

Follow these steps and your will be highlighting in no time!!!

  1. Go to your list to be highlighted
  2. Edit Page
  3. Add a Content Editor Web Part
  4. Move the CEWP to the bottom of the page
  5. Click the Edit Source button
  6. Copy and paste the following lines of code into the source code section
<script src=”/PublishingImages/javascript/jquery-1.3.2.min.js” type=”text/javascript”></script><script type=”text/javascript” language=”javascript”>var x = document.getElementsByTagName(“TD”) // find all of the TDsvar i=0;for (i=0;i<x.length;i++){if (x[i].className==”ms-vb2″) //find the TDs styled for lists{

if (x[i].innerHTML==”Next Day Pickup”) //find the data to use to determine the color

{

x[i].parentNode.style.backgroundColor=’yellow’; // set the color

}

}

}

</script>

  1. Make your changes to the innerHTML section to reflect the list value for the jquery lookup
  2. Set the color of your choosing.  You can also choose to use the html value for the color: FFFFOO

Please note, I am referencing jquery inside of my SharePoint site.  This way, I do not have to add an external reference.

How to Export a SharePoint User List to Excel

There may come a time when you may need to export your user list to excel.  It’s not that difficult.

  1. Copy the following path into notepad/word pad: http://yoursite.com/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=[LISTID]&View=[VIEWID]&CacheControl
  2. Minimize the text editor and navigate to Site Actions à Site Setting à People and Groups à All People.
  3. Click Settings on the option bar and click List Settings
  4. Click on “List View” under views.   This will take you to the “Edit View” screen
  5. Copy the url of the list view.  It will look similar to the following:http://yoursite.com/_layouts/ViewEdit.aspx?List=%7B02ACF6F6%2D8343%2D4244%2D81B8%2D68BF95F9C6D0%7D&View=%7B56BB9BDD%2DABB0%2D4CB6%2DA946%2D59A85A8EC2F9%7D&Source=%252F%255Flayouts%252Flistedit%252Easpx%253FList%253D02acf6f6%252D8343%2
    52D4244%252D81b8%252D68bf95f9c6d0%2526Source%253Dhttp%25253A%25252F%25252F
    spdev%25252Eprsontrack%25252Ecom%25252F%25255Flayouts%25252Fpeople%25252Easpx
    %25253FMembershipGroupId%25253D0%252526FilterField1%25253DContentType%252526
    FilterValue1%25253DPerson%252526View%25253D%25257B56BB9BDD%25252DABB0%2525
    2D4CB6%25252DA946%25252D59A85A8EC2F9%25257D%252526Filter%25253D1
  6. Copy the “List” and “View” IDs for the url that was created in step 5.  You list id will follow “List=”.  The same applies for the view id.  Here is the example from above: List=%7B02ACF6F6%2D8343%2D4244%2D81B8%2D68BF95F9C6D0%7D&View=%7B56BB9BDD%2DABB0%2D4CB6%2DA946%2D59A85A8EC2F9%7D
  7. From this example, copy %7B02ACF6F6%2D8343%2D4244%2D81B8%2D68BF95F9C6D0%7D and replace [LISTID] from step one.  This includes replacing the LISTID and the brackets.  Also, do not include the & symbol.  Follow the same steps for the “View”.
  8. Once you have finished, your completed url should look like this:http://yoursite.com/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=%7B02ACF6F6%2D8343%2D4244%2D81B8%2D68BF95F9C6D0%7D&View=%7B56BB9BDD%2DABB0%2D4CB6%2DA946%2D59A85A8EC2F9%7D&CacheControl
  9. Open a browser, and copy and paste the completed url that you completed in step 8.
  10. A window will pop up asking you to open or save the file.  Click open and the file will open in excel.
  11. A security warning will also pop up.  Click enable.
    open_excel

 

 

 

 

 

12.  After you are finished making your changes, you can save this like any other Excel file.

 

 

 

Dataview Web Part – Access Denied

The Problem

When a user that is restricted from a specific list visits the site; the view of that list displays an access denied message rather than hiding the Web Part from the user.  It appears that the security for the list is evaluated prior to the Web Part evaluating the targeted audiences.  Since the user does not have access to the list, the access denied message is shown as a result.

 


The Solution

We can remedy this issue by granting the lowest privilege on the list for the user.  As a requirement, the user must not be able to view any list items, so we will give the user the ability to see the list, but not the ability to see any items in the list. This is accomplished by creating a custom permission level that will contain ONLY the Open permission from the Site permissions group.  This will allow users possesing this permission to open the list, but will not grant them the permission to open any items in the list.  Grant the newly created permission level to the restricted users on the list and the audience targeting on the list views will now function as intended.

Happy Birthday Web Part

I wanted to be able to show all of the employees birthday’s for the current day.  Turns out, this was not a very hard task to accomplish.  I have a field in one of my lists’ that contains a birth date field.  All of the months and days are accurate, but the years are all set to 1996 for security reasons.  In order to show upcoming birthdays, I needed to change a few things.

Here’s the deal with that.  The “Birthdate” field holds the actual birthday of the user.  In my case, 24-Jul-96.  However, I want to see it as July 24 2010.

Well, since the [Today] field in calculated column will not work (all tricks will not work – the field won’t update!), here is a solution that only asks for a yearly update to the column.

First, I created a calculated column that results in the current year “Birthdate”.  This changed the view of the date from 24-Jul-96 to July 24 2010.  Note:  “Birthdate” is the name of the column in my list that contains the actual birthday.  Yours may vary.

  1. Create a calculated column to hold this year’s birth date named “Birthday”.
  2. Set the output type of the calculated value to “Date and Time”.
  3. Set the date and time format to “Date Only”.
  4. Use this formula to generate its value.

=DATE(2010,MONTH(Birthdate),DAY(Birthdate))

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5.  Create a new view of the list named “Birthday” and click on the plus to expand “Filter”.

6.  Next, enter in the following.  Once you click Ok, you will see all birthdays for the upcoming week.

 

 

 

 

 

 

 

 

 

 

 

 

7.  If you only want to see the birthdays for the current day only, simply change the filter to the following.

 

 

 

 

 

 

 

 

 

 

 

 

 

Just remember – next year you will have to update the formula of the calculated column from 2010 to 2011.

Enjoy!

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

Show Start and End time on a SharePoint calendar

If you have ever wondered if  it would be hard to show both the start and end times on a SharePoint calendar, stop wondering!

This can be performed in six simple steps.

  1. Create a calculated column.  Name the column “Time of Event”
  2. Insert this formula: =TEXT([Start Time],”h:mm AM/PM”)&” – “&TEXT([End Time],”h:mm AM/PM”)&” : “&Title
  3. For data type, select “Date and Time”
  4. For date and time format, select “Date and Time”
  5. Click OK
  6. Modify Calendar View:  Change monthly view title under calendar columns to “Time of Event”

The new entry will look similar to the image below:

Improperly setup AD account can cause issues

If you are using the people picker column in a list, watch out.  You could be faced with an odd little issue.

Recently, I created a list to control the views in an InfoPath form.  This list uses a people picker column that pulls the “UserName”.  What I noticed was that three of the users were displaying differently.  Instead of all lowercase letters, the first two letters of the username were capitalized.  As it happens, one of those users was unable to see a certain view that they had access to.

I had our AD guy change the names of the users to all lowercase letters.  I then ran a full AD import into SharePoint.  I waited a little while, pressed CTRL+F5 on my keyboard and noticed that the name changed in the permission checking list.

I logged in as the user and was now able to see the correct view.  Weird huh?

SharePoint 2007 – Enable left navigation for Web Part pages

If you have published an InfoPath form to a SharePoint site, chances are that you have created a webpart page and have published it there.
We part pages are great but you lose the left navigation and it can become confusing to some users.

There is however a simple fix that will enable the left nav for your pages. You will need to open up SharePoint Designer to do this.

  1. Open SharePoint Designer and navigate to your page
  2. Switch to code view and scroll down until approximately line 45.
  3. You see the following two lines.
  4. Highlight these two lines and delete.
  5. Save your page and that’s it!

<asp:Content ContentPlaceHolderId=”PlaceHolderLeftNavBar” runat=”server”></asp:Content>
<asp:Content ContentPlaceHolderId=”PlaceHolderNavSpacer” runat=”server”></asp:Content>
It will look similar to the image below:

Weird option button behavior

Just received a message that one of my forms was not behaving properly.  It seems that when someone seleted one of the option buttons in a set, more than one option would get selected.  I said to myself, “This is not possible.  You can only select one option at a time.”

Well, come to find out, I was right except for one minor detail.  When I double clicked on one of the buttons in design mode to show me the value, I noticed that it had the same value as another option button.  So whenever one was selected, both would populate and give the incorrect value.  I changed the value and now all is well.

Moral of the story……make sure to triple check your values.  It will cause a lot less grief down the road.