datagrid固定的代码----星星级的都过来看一下
查找很多,几乎都是这个代码,可是我自己用的时候怎么就实现不了了,问题出现在什么地方呢
代码如下:
<script language= "javascript ">
function ScrollDataGrid()
{
var tb = document.getElementById( "tbHeader ");
var dg = document.getElementById( "DataGrid1 ");
if(dg!= null)
{
var dv = document.getElementById( "dvBody ");
var th = dg.rows[0];
for(var i = 0 ; i < th.cells.length;i++)
th.cells[i].width = th.cells[i].clientWidth;
var tr = th.cloneNode(true);
//tr.applyElement(tb);
tb.createTHead();
var tbh = tb.tHead;
tbh.appendChild(tr);
tr = tbh.rows[0];
var td = tr.insertCell();
td.style.width = 19;
td.width = 19;
td.innerHTML = tr.cells[0].innerHTML;
th.style.display = 'none ';
if(dg.scrollHeight < 300 )
dv.style.height = dg.scrollHeight * 1 + 2;
}
}
</script>
<table width= "100% " border= "0 " id= "tbheader " cellpadding= "4 " cellspacing= "0 ">
</table>
<DIV style= "OVERFLOW-Y:scroll;HEIGHT:300px " id= "dvbody ">
<asp:datagrid id= "DataGrid1 " runat= "server " Width= "656px " Height= "264px " AutoGenerateColumns= "False ">
<Columns>
<asp:BoundColumn DataField= "jan " HeaderText= "jan ">
<ItemStyle Font-Size= "X-Small "> </ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField= "catcode " HeaderText= "catc