javascript - Make Fixed Gridview Header to ignore browser Scroll-bar JQuery -


is there way have fixed header respond 1 scroll bar in jquery? in case respond div scroll bar , not browser scroll bar. or there different solution. tried getting rid of browser scroll bar gridview contend wont accessible.

background: have jquery cloned gridview header inside of div scrolling bars, code:

    function fixedheader() {         // code copy gridview header style         var gridheader = $('#<%=gridview1.clientid%>').clone(true).attr('id','clonedgrid');          //code remove rows except header row         $(gridheader).find("tr:gt(0)").remove();         $('#<%=gridview1.clientid%> tr th').each(function (i) {             // here set width of each th gridview new table th              $("th:nth-child(" + (i + 1) + ")", gridheader).css('width', ($(this).width()).tostring() + "px");         });         // append header div controlhead         $("#controlhead").append(gridheader);         // set position fixed         $('#controlhead').css('position', 'fixed');         // put on top         $('#controlhead').css('top', $('#<%=gridview1.clientid%>').offset().top);     } 

it works perfect when window maximized when re-size browser , browser scroll bar appears, header obey both scroll bars (the 1 div , 1 browser) making header move when scroll browser scroll bar making fixed header off see below!![enter image description here]1.

so modified jquery code change absolute, , add z index, along setting height of each th grid new cloned table how code looks , works 100%

    function fixedheader() {         // code copy gridview header style         var gridheader = $('#<%=gridview1.clientid%>').clone(true).attr('id','clonedgrid');          //code remove rows except header row         $(gridheader).find("tr:gt(0)").remove();         $('#<%=gridview1.clientid%> tr th').each(function (i) {             // here set width of each th gridview new table th              $("th:nth-child(" + (i + 1) + ")", gridheader).css('width', ($(this).width()).tostring() + "px");             // here set height of each th gridview new table th              $("th:nth-child(" + (i + 1) + ")", gridheader).css('height', ($(this).height()).tostring() + "px");         });         // append header div controlhead         $("#controlhead").append(gridheader);         // set position fixed         $('#controlhead').css('position', 'absolute');         // bring header in front of else         $('#controlhead').css('z-index', '200');         // put on top         $('#controlhead').css('top', $('#<%=gridview1.clientid%>').offset().top);     } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -