Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on the senerio where i need to fix the gridview header in while scrolling in firefox & Chrome

My code is working well in IE but not working in firefox & Chrome.

Please have a look on the code.

Css to freeze the HeadeRow

CSS
.Freezing
      {
          position:relative ;
          background-color: #902b01;
          font-family: Arial, Helvetica, sans-serif;
          font-size: 10px;
          font-weight: normal;
          padding: 5px;
          white-space: nowrap;
      }



<HeaderStyle CssClass="Freezing" />


SQL
i am just using CSS to freeze the HeaderRow which is working well in IE but not in other one and i need to do it in FireFox & Chrome

Please help me in this.

Thanks
Posted

Have a look at the following article, it says that it works on IE, Firefox & Chrome:
Grid View with Fixed Header[^]
 
Share this answer
 
Comments
VJ Reddy 10-May-12 20:23pm    
Good find. 5!
Sandeep Mewara 10-May-12 22:38pm    
Yeah. Thanks.
Pankaj Nikam 24-Sep-12 9:21am    
+5 :) awesome share.
Sandeep Mewara 24-Sep-12 9:24am    
Thanks.
position:relative ;


It is for IE

position:fixed ;


It is for Firefox,chrome,etc...
 
Share this answer
 
v2
HI Ashish,
I think I have solution of this.
please see below javascript code


var orgTop = 0;
$(document).scroll(function () {

var id = $("tr:.header").get(0);
//alert(id)
var offset = $(id).offset();
var elPosition = $(id).position();
var elWidth = $(id).width();
var elHeight = $(id).height();
if (orgTop == 0) {
orgTop = elPosition.top;
}
if ($(window).scrollTop() &lt;= orgTop) {

id.style.position = 'relative';
id.style.top = 'auto';
id.style.width = 'auto';
id.style.height = 'auto';
}
else {
id.style.position = 'absolute';
id.style.top = $(window).scrollTop() + 'px';
id.style.width = elWidth + 'px';
id.style.height = elHeight + 'px';
}
});


where [.header] is the css class of your Grid header.
Just add this script on the page and replace [header] with the css class name you have used for your header.
 
Share this answer
 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900