0

Sounds Simple, and I'm hoping it should be. But I have a sharepoint 2013 list and cannot for the life of me adjust the column widths. Some need to be smaller, some need to be wider. I have found several articles where they said to find 'x' piece of code, which never seems to exist in my designer view.

Another example I tried with no luck is to edit the javascript with a .txt file and upload that file to site assets, copy the link into a new content editor. Nothing.

Seems like this should be very easy. Am I missing something here?

1

You can change the width (or anything) using CSS.

<style type='text/css'>
.ms-vh-div[DisplayName='ColumnName']
{
  width:250px;
}
</style>

If you need to add this CSS to a page where you have multiple lists, you can target a specific list/webpart by using F12 Developer Tools to find the web-part ID and add it before .ms-vh-div.

#WebPartWPQX .ms-vh-div[DisplayName='ColumnName'] 

Where X is the number/ID of the webpart.

0

Follow the below steps to achieve this

  1. Create a txt file containing the code below:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>

    <script type="text/javascript">

    $(document).ready(function() {

    $("TH.ms-vh2:contains('Title')").css("width", "300px");

    //You can change the column to be the column you want to change the width,you can apply to multiple columns by copying that code line and change the column name and width

    });

    `

  2. Upload the txt file to a library in SharePoint.

  3. Add a Content Editor in the page where the list that you want to change the width of the column exists, and then edit the web part.

  4. In Content Link, type in the URL of the txt file in SharePoint, like http://server/site/library/file.txt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.