Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

ms-vh2 exists by verifying "view source" but I cant get the following code to do the tricks for me. any idea??

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function()
{
    $("tr.ms-viewheadertr th:contains('Name')").css("width", "315px");
    //$("TH.ms-vh2:contains('Name')").css("width", "50px");
    //$("TH.ms-vh2-nograd:contains('Title')").css("width", "350px");
    //$("TH.ms-vh2:contains('LongDescription')").css("width", "350px");
});
</script>
share|improve this question

1 Answer 1

up vote 1 down vote accepted

The selector is working for me. Try this to see if the selector is working for you:

$("th.ms-vh2:contains('Name')").css("background-color", "red");  

It might be that your selector is working, but the css seems like it isn't. What I mean by this is that I can't reduce the width of the <th> to 1px because the content that it contains won't allow it to be that small.

share|improve this answer
    
Red background works. However, no matter what i put 1px or 1000 px it does not change. i think ootb css overwrites the width piece. –  Mary Rivers Oct 19 '11 at 19:40
    
I guess Marc is right . endusersharepoint.com/STP/viewtopic.php?f=13&t=959 You're adjusting the table header cell (TH), but not the table detail cells (TDs) below them. The widest cell usually wins. –  Mary Rivers Oct 19 '11 at 20:00
    
I was able to adjust the width, but was not able to make it that small. Check out this article. blogs.msdn.com/b/saurabhkv/archive/2009/06/22/… You can use the _spBodyOnLoadFunctionNames.push method to ensure the body of the document has loaded before your JQuery runs. –  Panter Oct 19 '11 at 20:10
    
I thank you for trying this for me and find a solution. But this did not work for me. <script language="javascript"> _spBodyOnLoadFunctionNames.push("FunctionName"); function FunctionName() { // Code } </script> –  Mary Rivers Oct 20 '11 at 13:48
    
Actually, I turned on the developer tools for IE and I get an error on this line _spBodyOnLoadFunctionNames.push('ColumnWidth'); I tried _spBodyOnLoadFunctionNames.push("ColumnWidth"); but same error –  Mary Rivers Oct 20 '11 at 14:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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