Saturday, July 25, 2015

script to set column width in sharepoint list/libraries

<script type="text/javascript" src="/SiteAssets/jquery-2.1.3.min.js">   </script>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>


<script type="text/javascript">
$(document).ready(function () {
 setInterval(function(){ 
  $Text = $("td.ms-cellstyle.ms-vb2:contains('Approved')"); $Text.css("color", "#01DF3A");
    $Text = $("td.ms-cellstyle.ms-vb2:contains('Cancelled')");
    $Text.css("color", "RED");
    $Text = $("td.ms-cellstyle.ms-vb2:contains('Pending')");
    $Text.css("color", "#EAC117");

$(function(){
$("div.ms-vh-div:contains('Description')").css("width", "350px");
}); 
}, 1000);
  
//$('#MSOZoneCell_WebPartWPQ5.ms-alternating' ).css('background-color','navy'); 

});
</script>

1 comment:

  1. You can also set the column width in pure CSS...

    <*style>
    .ms-vh-div[DisplayName='ColumnName']
    {
    width : 200px !important;
    }
    <*/style>

    (* in tag because HTML tags are not accepted in the comment section)

    ReplyDelete