一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

javascript之鎖定表格欄位

<HTML><HEAD><TITLE>鎖定表格欄位范例網(wǎng)頁(yè)</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>BODY {
       FONT: 12px 細(xì)明體; CURSOR: default
}
TD {
       FONT: 12px 細(xì)明體; CURSOR: default
}
.title {
       BORDER-RIGHT: #555 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #fff 1px solid; PADDING-LEFT: 4px; BACKGROUND: #ccc; PADDING-BOTTOM: 4px; OVERFLOW: hidden; BORDER-LEFT: #fff 1px solid; CURSOR: hand; PADDING-TOP: 4px; BORDER-BOTTOM: #555 1px solid; WHITE-SPACE: nowrap
}
.cdata {
       BORDER-RIGHT: #ddd 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #fff 1px solid; PADDING-LEFT: 3px; BACKGROUND: #fff; PADDING-BOTTOM: 3px; OVERFLOW: hidden; BORDER-LEFT: #fff 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #ddd 1px solid; WHITE-SPACE: nowrap
}
</STYLE>

<SCRIPT language=JavaScript >
// 欄位標(biāo)題 ( 欄位名稱(chēng) # 欄位寬度 # 資料對(duì)齊 )
var DataTitles=new Array(
"歌手 / 團(tuán)體#90 #left"  ,
"專(zhuān)輯名稱(chēng)   #130#left"  ,
"發(fā)行公司   #110#left"  ,
"本周排名   #58 #center",
"排名狀況   #58 #center",
"上周排名   #58 #center",
"上榜周數(shù)   #58 #center",
"最高名次   #58 #center",
"銷(xiāo)售百分比 #70 #center")

// 欄位資料 ( 二維陣列 )
var DataFields=new Array()
DataFields[0] =new Array("蕭亞軒"  ,"愛(ài)的主打歌-吻"   ,"維京 Virgin"    ,"1" ,"持平"  ,"1" ,"2","1" ,"2.9 %")
DataFields[1] =new Array("張惠妹"  ,"發(fā)燒"            ,"華納 Warner"    ,"2" ,"持平"  ,"2" ,"2","2" ,"2.1 %")
DataFields[2] =new Array("陶吉吉"  ,"黑色柳丁"        ,"全員集合 Shock" ,"3" ,"持平"  ,"3" ,"5","1" ,"1.8 %")
DataFields[3] =new Array("S.H.E"   ,"美麗新世界"      ,"華研 HIM"       ,"4" ,"持平"  ,"4" ,"6","1" ,"1.2 %")
DataFields[4] =new Array("艾薇兒"  ,"展翅高飛"        ,"博德曼 BMG"     ,"5" ,"新進(jìn)榜","-" ,"1","5" ,"1.1 %")
DataFields[5] =new Array("任賢齊"  ,"一個(gè)任賢齊"      ,"滾石 Rock"      ,"6" ,"新進(jìn)榜","-" ,"1","6" ,"1.0 %")
DataFields[6] =new Array("范逸臣"  ,"范逸臣第一張專(zhuān)輯","豐華 Forward"   ,"7" ,"持平"  ,"7" ,"2","7" ,"0.9 %")
DataFields[7] =new Array("謝霆鋒"  ,"無(wú)形的他全精選"  ,"新力 Sony"      ,"8" ,"下跌"  ,"6" ,"4","4" ,"0.9 %")
DataFields[8] =new Array("周蕙"    ,"寂寞城市"        ,"福茂 Decca"     ,"9" ,"下跌"  ,"5" ,"3","5" ,"0.8 %")
DataFields[9] =new Array("周杰倫"  ,"八度空間"        ,"博德曼 BMG"     ,"10","下跌"  ,"8" ,"8","1" ,"0.8 %")
DataFields[10]=new Array("酷玩樂(lè)團(tuán)","玩過(guò)頭"          ,"科藝百代 EMI"   ,"11","上升"  ,"16","2","11","0.7 %")
DataFields[11]=new Array("張震岳"  ,"等我有一天"      ,"魔巖 Magicstone","12","新進(jìn)榜","-" ,"1","12","0.6 %")
DataFields[12]=new Array("堂本剛"  ,"紅與藍(lán)"          ,"艾回 Avex"      ,"13","新進(jìn)榜","-" ,"1","13","0.6 %")
DataFields[13]=new Array("ENERGY"  ,"COME ON"         ,"環(huán)球 Universal" ,"14","下跌"  ,"10","9","5" ,"0.6 %")
DataFields[14]=new Array("陳冠希"  ,"TRANSITION"      ,"艾回 Avex"      ,"15","下跌"  ,"9" ,"3","5" ,"0.4 %")
DataFields[15]=new Array("合輯"    ,"MTV 嘻哈大師"    ,"環(huán)球 Universal" ,"16","下跌"  ,"12","3","12","0.4 %")

</SCRIPT>

<SCRIPT language=JavaScript>
var BoxWidth = 480        // 資料表顯示寬度 ( 不含卷軸 )
var ShowLine = 10        // 資料表顯示列數(shù)
var RsHeight = 21        // 資料列高度
var LockCols = 1        // 要鎖定的欄位數(shù) ( 由左至右 )

function WriteTable(){        // 寫(xiě)入表格
var iBoxWidth=BoxWidth
var NewHTML="<table border=/"0/" cellpadding=/"0/" cellspacing=/"0/"><tr>/
<td><div style=/"width:100%;overflow-x:scroll/">/
<table border=/"0/" cellpadding=/"0/" cellspacing=/"0/"><tr>"
for(i=0;i<DataTitles.length;i++){
 if(i<LockCols){
   var cTitle=DataTitles[i].split("#")
   iBoxWidth-=cTitle[1]
   var DynTip=((i+1)==LockCols)?"解除鎖定":"鎖定此欄位"
   NewHTML+="<td><div class=/"title/" style=/"width:"+cTitle[1]+"px;height:"+RsHeight+"px/" title=/""+DynTip+"/" onclick=/"ResetTable("+i+")/">"+cTitle[0]+"</div></td>"
 }
}
NewHTML+="</tr>/
<tr><td colspan=/""+LockCols+"/">/
<div id=/"DataFrame1/" style=/"position:relative;width:100%;overflow:hidden/">/
<div id=/"DataGroup1/" style=/"position:relative/"></div></div>/
</td></tr></table></div></td>/
<td valign=/"top/"><div style=/"width:"+iBoxWidth+"px;overflow-x:scroll/">/
<table border=/"0/" cellpadding=/"0/" cellspacing=/"0/"><tr>"
for(i=0;i<DataTitles.length;i++){
 if(i>=LockCols){
   var cTitle=DataTitles[i].split("#")
   NewHTML+="<td><div class=/"title/" style=/"width:"+cTitle[1]+"px;height:"+RsHeight+"px/" title=/"鎖定此欄位/" onclick=/"ResetTable("+i+")/">"+cTitle[0]+"</div></td>"
 }
}
NewHTML+="</tr>/
<tr><td colspan=/""+(DataTitles.length-LockCols)+"/">/
<div id=/"DataFrame2/" style=/"position:relative;width:100%;overflow:hidden/">/
<div id=/"DataGroup2/" style=/"position:relative/"></div>/
</div></td></tr></table>/
</div></td><td valign=/"top/">/
<div id=/"DataFrame3/" style=/"position:relative;background:#000;overflow-y:scroll/" onscroll=/"SYNC_Roll()/">/
<div id=/"DataGroup3/" style=/"position:relative;width:1px;visibility:hidden/"></div>/
</div></td></tr></table>"
DataTable.innerHTML=NewHTML
ApplyData()
}

function ApplyData(){        // 寫(xiě)入資料
var NewHTML="<table border=/"0/" cellpadding=/"0/" cellspacing=/"0/">"
for(i=0;i<DataFields.length;i++){
 NewHTML+="<tr>"
 for(j=0;j<DataTitles.length;j++){
   if(j<LockCols){
     var cTitle=DataTitles[j].split("#")
     NewHTML+="<td><div class=/"cdata/" style=/"width:"+cTitle[1]+"px;height:"+RsHeight+"px;text-align:"+cTitle[2]+"/">"+DataFields[i][j]+"</div></td>"
   }
 }
 NewHTML+="</tr>"
}
NewHTML+="</table>"
DataGroup1.innerHTML=NewHTML


var NewHTML="<table border=/"0/" cellpadding=/"0/" cellspacing=/"0/">"
for(i=0;i<DataFields.length;i++){
 NewHTML+="<tr>"
 for(j=0;j<DataTitles.length;j++){
   if(j>=LockCols){
     var cTitle=DataTitles[j].split("#")
     NewHTML+="<td><div class=/"cdata/" style=/"width:"+cTitle[1]+"px;height:"+RsHeight+"px;text-align:"+cTitle[2]+"/">"+DataFields[i][j]+"</div></td>"
   }
 }
 NewHTML+="</tr>"
}
NewHTML+="</table>"
DataGroup2.innerHTML=NewHTML
DataFrame1.style.pixelHeight=RsHeight*ShowLine
DataFrame2.style.pixelHeight=RsHeight*ShowLine
DataFrame3.style.pixelHeight=RsHeight*ShowLine+RsHeight
DataGroup3.style.pixelHeight=RsHeight*(DataFields.length+1)
}

function ResetTable(n){
var iBoxWidth=0
for(i=0;i<DataTitles.length;i++){
 if(i<(n+1)){
   var cTitle=DataTitles[i].split("#")
   iBoxWidth+=parseInt(cTitle[1])
 }
}
if(iBoxWidth>BoxWidth){
 var Sure=confirm("/n鎖定欄位的寬度大於資料表顯示的寬  /n/n度,這可能會(huì)造成版面顯示不正常。/n/n/n您確定要繼續(xù)嗎?")
}else{
 Sure=true
}
if(Sure){
 LockCols=(LockCols==n+1)?0:n+1
 WriteTable()
}
}

function SYNC_Roll(){
DataGroup1.style.posTop=-DataFrame3.scrollTop
DataGroup2.style.posTop=-DataFrame3.scrollTop
}
window.onload=WriteTable
</SCRIPT>

<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY>
<CENTER>
<H4>鎖定表格欄位范例網(wǎng)頁(yè)</H4><!--// 資料表 ( 開(kāi)始 ) //-->
<TABLE cellSpacing=0 cellPadding=0 border=0>
 <TBODY>
 <TR>
   <TD 
   style="BORDER-RIGHT: white 2px inset; BORDER-TOP: white 2px inset; BORDER-LEFT: white 2px inset; BORDER-BOTTOM: white 2px inset; BACKGROUND-COLOR: scrollbar">
     <DIV id=DataTable></DIV></TD></TR></TBODY></TABLE><!--// 資料表 ( 結(jié)束 ) //-->
<P>點(diǎn)取欄位標(biāo)題可重新設(shè)定或解除目前的鎖定狀態(tài)</P></CENTER></BODY></HTML>

JavaScript技術(shù)javascript之鎖定表格欄位,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 中文免费观看视频网站 | 九九国产 | 国产香蕉久久精品综合网 | 一本色道久久88 | 爱做久久久久久久久久 | 国产国产成人精品久久 | 天天更新天天久久久更新影院 | 精品久久久中文字幕一区 | 91亚洲视频在线观看 | 亚洲欧美日韩视频一区 | 午夜色大片在线观看 | 亚洲国产色婷婷精品综合在线观看 | 国产情侣真实露脸在线最新 | 国产剧情在线视频 | 1024国产基地永久免费 | 91视频免费网站 | 国产成人精品视频午夜 | 久草黄色| 91久久国产情侣真实对白 | 有一婷婷色 | 激情综合在线观看 | 国产在线免 | 国产成人小视频 | 欧美成人久久久 | 成人观看天堂在线影片 | 欧美极品欧美精品欧美图片 | 最色网在线观看 | 极品美女在线观看 | 亚洲一区二区三区免费看 | 国产成人在线视频免费观看 | 亚洲区一二三四区2021 | 免费欧美一级 | 国产精品国内免费一区二区三区 | 色噜噜国产在线91蝌蚪 | 欧美成人三级 | 亚洲三级天堂 | 国产福利在线小视频 | 女人18毛片久久鬼色 | 91最新在线视频 | 色婷婷婷婷 | 国产激情视频在线观看首页 |