1

I found the script below for controlling the width of a SP column elsewhere on this site. What SharePoint file would I insert this code in or can I just create a file with the code (and proper column name) and upload it to the SharePoint web site with an aspx file extension in one of the sub-folders? Thanks!

Use this javascript in your page:

<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('Name')").css("width", "300px"); //You can change the Column Name to be the column you want to change the width, Title in the code for example.
    });
</script>
  • Will this work for columns in libraries? – Chuck Dec 14 '18 at 15:01
0

You can use Script Editor or Content Editor webpart to add your HTML/Javascript code on your page.

Follow the steps given in below link to add your code in Script Editor:

How to Use the Script Editor Web Part in SharePoint 2013

  • Will this work for columns in libraries? – Chuck Dec 14 '18 at 16:53
  • Yes, if the selectors and code is correct it will. – Ganesh Sanap Dec 14 '18 at 17:27

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.