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.