So I'm using the below formula to try to set my column widths for a column called title, but it doesn't seem to be working:

<!--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(){$("TH.ms-vh2-nograd:contains('Title')").css("width", "150px"); $("TH.ms-vb:contains('Title')").css("width", "150px"); }); </script>

Believe this should be working, because when I view source, I see;

class="ms-vh2"div style="width:100%;position:relative;left:0;top:0;"TABLE style="width:100%;" Sortable="" SortDisable="" FilterDisable="" Filterable="" Name="LinkTitle" CtxNum="2" DisplayName="Title" FieldType="Computed" ResultType="" SortFields="SortField=LinkTitle&amp;SortDir=Asc&amp;View=%7bE2B0E597%2d8A06%2d4365%2dA48C%2d00B47A7CFE24%7d&amp;PageView=Shared" height="100%" cellspacing=1 cellpadding=0 class="ms-unselectedtitle"


  • Rob, Did you ever get this to work? I have the same requirement, and tried your code above with no success.
    – user2429
    Feb 16, 2011 at 17:09
  • Rob, when you say it's not working... what's it doing? Is the TH greater than or less than 150px? Mar 10, 2011 at 20:44

2 Answers 2


Original Comment: Want to try that again as a code sample?

Edit, with actualy Answer:

Thanks. That helps.

What I think you're running up against is that your jQuery is running before the page is finished loading. Try this:

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

  $(document).ready( function(){
      $("TH.ms-vh2-nograd:contains('Title')").css("width", "150px");
      $("TH.ms-vb:contains('Title')").css("width", "150px");


Maybe you would do better to fetch the dynamic control id and work from there.

var $trackingGridID = $("[id$=_ListViewWebPartJSGrid_leftpane_mainTable]").attr("id");
$('#' + trackingGridID).css("background-color", "blue");

this will fetch this control id:


Here is my similar question with regards to column widths on a GANTT chart.

Your Answer

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