7

How can I increase the column width in a list view web part?

1

5 Answers 5

12

To increase the width of a particular column in the List View Web Part

Add a Content Editor Web Part in your page

Add the below css text in it and save.

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

You can get the <ColumnName> from the source of the table. [F12]

3
  • Hi this is not functional using Sharepoint 2010, is it possible the class changed? I have tried just about every combination of this, including .ms-vh div instead of .ms-vh-div, additionally with different columns to test it. It appears right to me even when inspecting the CSS with F12.
    – Shackrock
    Aug 31, 2016 at 22:05
  • its working for me. just made slight modification to the code.. i.e. i did same using jQuery.. and changed the width of the parent of .ms-vh-div.. this class is giving us the div which is inside th, change the width of this th by using code like this : $("div.ms-vh-div[name='Title']").parent().css("width","25%") It will work :) Oct 3, 2016 at 13:14
  • what if i have 20 views ? Do I need to add in every view
    – Light
    Jan 16, 2019 at 12:33
3

I couldn't resize the grabby part in the th without breaking it, but this works in a Content Editor Web Part:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
  setTimeout(function(){
    $("th[title='Title']").css({"width":"400px"})
  }, 2000)
})
</script>
2

There is a workaround to set the column width, but it will effect all columns.

Check the CSS of ListViewWebPart's Html Table (via view source code or IE Dev toolbar)

Consider, ListViewWebPart's Table class name is - .msTable

Then write an inline CSS in your aspx page like

.msTable TD
{
   width:80px;
}

The above code will set the width fixed for column inside ListViewWebPart.

2
  • Hi saumilm, thanks for posting an answer but this is not what I want. I want to adjust column width in list view WEB PART and not list view. Please read my question again.
    – Zakir HC
    Aug 8, 2012 at 10:48
  • Long dead post, but his logic should help (so long as a list view web part has a table). Go to the rendered screen (I'm using Chrome, so steps may vary), inspect one of the cells in the top of your list view's table preferably near the top, now go up until you see the <table value. At that point look for the class attached and replace with that. In my case, it was .ms-listviewtable so it'd be .ms-listviewtable td { }
    – Robert
    May 13, 2015 at 15:31
0
  1. Open the List in Sharepoint designer and then select column (header of the column) of which you wish to increase the width and select the properties for that and select CSS Style to open the styling window and then set the width in it.

    1. Then from the top bar menu select "Insert Tab" then from it select "Customize XSLT-> Customize entire view"

    2. Goto the header of the column from the markup view and find something like "<th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)">" tag for that column and remove - nowrap="nowrap"

and save it and test, it would work fine!

0

Solution for me was very simply. As soon as multiple [Space]s are not working because are shortened by design, I extended the name of column in setting by using char from ASCII like that: [ALT]+255. It is an invisible char. You can write as many chars as you wish in the tittle of the column and it will make it wider.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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