1

I am looking for a way, in a SP2019 List, to freeze Column 1 (or Columns 1, 2, 3) when scrolling to the right. I do not have access to SPD. JQuery would be great.

Thank you!

1 Answer 1

1

I have one jQuery with content editor web part that I had used in my SharePoint 2013 on-prem server site to freeze the first 2 columns. This may help you but it may require some adjustments as per SP2019.

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
    var table = $('.ms-listviewtable');
    var firstCol = table.find('tr').find('td:nth-child(1), th:nth-child(1)');
    var secondCol = table.find('tr').find('td:nth-child(2), th:nth-child(2)');

    firstCol.css({
        'position': 'sticky',
        'left': '0',
        'background': '#fff',
        'z-index': '1'
    });

    secondCol.css({
        'position': 'sticky',
        'left': '100px', // Adjust this value based on the width of the first column
        'background': '#fff',
        'z-index': '1'
    });
});
</script>
2
  • Thank you Dikesh! I usually have the ID column and the Edit icon in the first few columns so I'm going to play with it a bit, but this works perfectly! Thanks again. Cheers!
    – ChasEpes
    Commented Dec 2 at 15:45
  • Ha! This is the 2nd script that only appears to work in Chrome and not Edge. Ugh
    – ChasEpes
    Commented Dec 2 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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