Sharepoint 2010 - How do you freeze the column headers in a list?
I have tried many of the scripts on the internet but none are working. Is there a HTML that I could use?
Thanks
Technology Tips and News
Sharepoint 2010 - How do you freeze the column headers in a list?
I have tried many of the scripts on the internet but none are working. Is there a HTML that I could use?
Thanks
Hi,
Please change the "SummaryName" to your list name in the code below and add the code into a content editor web part in the list view page.
<script type="text/javascript"> function TTNListScroll() { //custom list name var SummaryName = "CustomList1"; var TTNmyTable; var TTNListDiv = document.createElement('div'); var TTNHeadingDiv = document.createElement('div'); var tables = document.getElementsByTagName("TABLE"); for (var i=0;i<tables.length;i++) { if ( tables[i].summary.indexOf(SummaryName)>=0) { TTNmyTable = tables[i]; break; } } if(TTNmyTable == undefined) { //alert("table '" + SummaryName + "' not found"); return; } // make a copy of the table for the heading area TTNHeadingDiv.appendChild(TTNmyTable.cloneNode(true)); TTNHeadingDiv.id="TTNheading"; TTNListDiv.appendChild(TTNmyTable.cloneNode(true)); TTNListDiv.id="TTNlist"; TTNListDiv.width="100%"; // udpate the page var TTNnode = TTNmyTable.parentNode TTNnode.replaceChild(TTNHeadingDiv, TTNmyTable); TTNnode.appendChild(TTNListDiv); // hide the heading row of the main list TTNListDiv.childNodes[0].rows[0].style.visibility='hidden'; // make the DIV for the heading the same width as the main list TTNHeadingDiv.childNodes[0].style.width = TTNListDiv.childNodes[0].offsetWidth } // update the list after the page has loaded _spBodyOnLoadFunctionNames.push("TTNListScroll"); </script> <style type="text/css"> #TTNheading { height:28px; overflow:hidden; } #TTNlist { height:200px; overflow-y:scroll !important; overflow-x :auto } </style>
Best Regards,
Dennis
Hi Dennis
I cant get it to work - I am very new to scripts so probally doing something wrong.
I copied the script then changed the three times where it said "summaryname" to my list name (without spaces).
Then I copied it drcet into the content editor and also tried putting it in note pad - save and then copyied the link in to the content editior.
Please provide step by step help.
Thanks
forgot to say - its the column headers I want to scroll down as you scroll down the page.
Hi,
Please try to add more list items in the list.
I refer to the link below and change some code to make it works in my test environment.
http://techtrainingnotes.blogspot.com/2013/03/freezing-title-row-of-sharepoint-2010.html
I suggest you provide the screenshot further research.
Best Regards,
Dennis