How can I increase the column width in a list view web part?
5 Answers
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]
-
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. 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 -
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>
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.
-
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 HCAug 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 { }– RobertMay 13, 2015 at 15:31
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.
Then from the top bar menu select "Insert Tab" then from it select "Customize XSLT-> Customize entire view"
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!
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.