Need to modify the width of a SharePoint column in a view? jQuery!

I recently had a request on one of my sites to increase the size of the Description column in the SharePoint views. Out of the box, there’s no easy way to do that. But, with a little snippet of jQuery placed in a Content Editor Web Part on the page with the view, you can easily change any of the column widths…

Here’s the code I used:

<!--ADJUST TABLE COLUMN WIDTH-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript">
</script>
<script type="text/javascript">
$(function(){
$("div.ms-vh-div:contains('Description')").css("width", "350px");});</script>

If you have multiple columns to modify, just repeat the line with the “div.” string. This is so simple, my customer went in and made her own changes to the code.

Many thanks to Mark Miller, who provided the solution in the post SharePoint jQuery: Setting View Column Width.

 

4 responses to “Need to modify the width of a SharePoint column in a view? jQuery!

  1. Thank you! Thank you! Thank you!

  2. Mohammed Ruman

    Works!
    Thank you 🙂

  3. Hi, I tried applying this but it doesn’t seem to be working in edit mode or datasheet view mode? Has someone encountered the same problem?

  4. Yes.. It is not working in quick edit mode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s