change the size of the column in SharePoint list view


Source: http://www.sharepointblog.co.uk/change-size-column-sharepoint-list-view/

Do you know how SharePoint determines the size of the Multiline Text type column for the list view? I don’t think SharePoint knows that either. In essence, Multiline text columns, if there are several of them, seem to get their size from the heading text, so if the text is just one small word – then the entire column and it’s content will be all bunched up in a tiny little column.

SharePoint columns size is random

That’s not always convenient, so I thought it’d be cool to show you how you can control the size of the column using jQuery script. Ensure you have a latest version of the jQuery file (in my case it’s jquery-1.10.2.js). As always with these types of customizations, we will add a Content Editor Web Part on the top of the list view. The following is the code to be added to the web part.

<script src="/Shared%20Documents/jquery-1.10.2.js"></script>
<script language="javascript">

_spBodyOnLoadFunctionNames.push(“AdjustColumnWidth”);

function AdjustColumnWidth(){
$("div.ms-vh-div[DisplayName='BigColumn']").attr("style", "WIDTH: 550px");
$("div.ms-vh-div[DisplayName='Column1']").attr("style", "WIDTH: 550px");
$("div.ms-vh-div[DisplayName='Column2']").attr("style", "WIDTH: 550px");
}</script>

Above you will see three lines of code in the AdjustColumnWidth function:

$("div.ms-vh-div[DisplayName='Column2']").attr("style", "WIDTH: 550px");

See the part that has DisplayName=’Column2′, well change the “Column2″ to whatever is the display name of your Multiline text column. You can also change the width to whatever is the pixel size that you need your column to be. Save the web part content and the page and that’s it!

The result speaks for itself:

SharePoint columns size changed

3 thoughts on “change the size of the column in SharePoint list view

  1. Hello,

    I’m using your procedure, very interesting to me, in Sharepoint 2013 Online with Jquery 1.11.1
    The problem does not work.
    There are differences for Sharepoint 2013 Online?

    Thank you for your help

  2. I’ve tried this. It works on any column, not just multi-line text field columns. But I find that on some columns, the column won’t get resized via “div.ms-vh-div”. I can see in Firebug that this value gets set properly, but it doesn’t resize because the value is overridden by “td.ms-vb2”. It doesn’t happen on every column. I can get it to work on all kinds of columns except for a very long single-line-of-text column…

Leave a Reply

Please log in using one of these methods to post your comment:

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