麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > HTC > 正文

Web上功能強大的DbGrid表格HTC組件[只需在Table中指定樣式就可以完成多種功能可擴展]

2020-01-31 16:06:26
字體:
來源:轉載
供稿:網友

Grid.htm

復制代碼 代碼如下:

<style>
INPUT
{
DefineINPUTOnClick:expression(this.onclick=function(){if(this.type=="button"){this.style.color=chooseColor();}});
}
</style>
<script>
var iGridRowCount=0;
var iGridColCount=0;
function createGrid()
{
DivID.innerHTML="";
if(iGridRowCount==0){iGridRowCount=5;}
if(iGridColCount==0){iGridColCount=5;}
var vTable=document.createElement("table");
vTable.style.behavior="url(Grid.htc)";
if(defineGridBgColorID.style.color)
{vTable.defineGridBgColor=defineGridBgColorID.style.color;}
if(defineFirstRowBgColorID.style.color)
{vTable.defineFirstRowBgColor=defineFirstRowBgColorID.style.color;}
if(defineFirstColBgColorID.style.color)
{vTable.defineFirstColBgColor=defineFirstColBgColorID.style.color;}
if(defineCurRowBgColorID.style.color)
{vTable.defineCurRowBgColor=defineCurRowBgColorID.style.color;}
if(defineCurColBgColorID.style.color)
{vTable.defineCurColBgColor=defineCurColBgColorID.style.color;}
if(defineCurEditBgColorID.style.color)
{vTable.defineCurEditBgColor=defineCurEditBgColorID.style.color;}
for(mIndex=0;mIndex<iGridRowCount;mIndex++)
{
var vTr=vTable.insertRow(mIndex);
for(nIndex=0;nIndex<iGridColCount;nIndex++)
{
vTd=vTr.insertCell(nIndex);
vTd.innerText="行"+mIndex+"列"+nIndex;
}
}
DivID.appendChild(vTable);
}
function chooseColor()
{
var strColor=DlgHelper.ChooseColorDlg();
strColor=strColor.toString(16);
if(strColor.length<6)
{
var sTempString="000000".substring(0,6-strColor.length);
strColor=sTempString.concat(strColor);
}
return strColor;
}
</script>
<div id="DivID"></div>
<object id="DlgHelper" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></object>
<fieldset>
<button onclick="window.confirm('已實現功能')">Grid參數區</button><br>
<input type=button value="表格背景" id="defineGridBgColorID"><br>
<input type=button value="頭行背景" id="defineFirstRowBgColorID"><br>
<input type=button value="頭列背景" id="defineFirstColBgColorID"><br>
<input type=button value="當前選擇行背景" id="defineCurRowBgColorID"><br>
<input type=button value="當前選擇列背景" id="defineCurColBgColorID"><br>
<input type=button value="當前選擇編輯單元格背景" id="defineCurEditBgColorID"><br>
<button onclick="window.confirm('未實現功能')">保留功能區</button><br>
<input type=text value="" id="defineGridRowCount"><button onclick="iGridRowCount=defineGridRowCount.value;">行數</button><br>
<input type=text value="" id="defineGridColCount"><button onclick="iGridColCount=defineGridColCount.value;">列數</button><br>
<input type=radio>是<input type=radio>否啟動行調整<br>
<input type=radio>是<input type=radio>否啟動列調整<br>
<input type=radio>是<input type=radio>否啟動單元格編輯<br>
<button onclick="createGrid()">創建表格</button><br>
</fieldset>

Grid.htc
復制代碼 代碼如下:

<public:property name="defineGridBgColor">
<public:property name="defineFirstRowBgColor">
<public:property name="defineFirstColBgColor">
<public:property name="defineCurRowBgColor">
<public:property name="defineCurColBgColor">
<public:property name="defineCurEditBgColor">
<public:attach event=oncontentready onevent="initGrid()">
<script>
//常量[可以設置為屬性]
var rgbGridBgColor="#E1E4EC";//表格背景
var rgbFirstRowBgColor="#6699CC";//頭行背景
var rgbFirstColBgColor="#6699CC";//頭列背景
var rgbCurRowBgColor="#BBCCDD";//當前選擇行背景
var rgbCurColBgColor="#BBCCDD";//當前選擇列背景
var rgbCurEditBgColor="#FFFFFF";//當前選擇編輯單元格背景
//表格列數
var iColCount=0;
//表格行數
var iRowCount=0;
//當前選擇行
var iCurRowIndex=0;
//當前選擇列
var iCurColIndex=0;
var bIsDragRow=false;//行是否拖動狀態
var bIsDragCol=false;//列是否拖動狀態
var iDragHistoryRowIndex=0;//拖動前原始行位置索引
var iDragCurrentRowIndex=0;//拖動后目的行位置索引
var iDragHistoryColIndex=0;//拖動前原始列位置索引
var iDragCurrentColIndex=0;//拖動后目的列位置索引
function initGrid()
{
//屬性獲取
if(defineGridBgColor)
{rgbGridBgColor=defineGridBgColor;}else{rgbGridBgColor="#E1E4EC";}
if(defineFirstRowBgColor)
{rgbFirstRowBgColor=defineFirstRowBgColor;}else{rgbFirstRowBgColor="#6699CC";}
if(defineFirstColBgColor)
{rgbFirstColBgColor=defineFirstColBgColor;}else{rgbFirstColBgColor="#6699CC";}
if(defineCurRowBgColor)
{rgbCurRowBgColor=defineCurRowBgColor;}else{rgbCurRowBgColor="#BBCCDD";}
if(defineCurColBgColor)
{rgbCurColBgColor=defineCurColBgColor;}else{rgbCurColBgColor="#BBCCDD";}
if(defineCurEditBgColor)
{rgbCurEditBgColor=defineCurEditBgColor;}else{rgbCurEditBgColor="#FFFFFF";}
//初始化常量
iColCount=element.rows(0).cells.length;
iRowCount=element.rows.length;
//設置表格樣式
element.style.backgroundColor=rgbGridBgColor;
element.border="0";
element.cellSpacing="1";
element.cellPadding="0";
element.width="80%";
element.style.borderLeft="1px solid #000000";
element.style.borderBottom="1px solid #000000";
//設置單元格樣式
for(iRow=0;iRow<iRowCount;iRow++)
{
for(iCol=0;iCol<iColCount;iCol++)
{
element.rows(iRow).cells(iCol).style.borderTop="1px solid #000000";
element.rows(iRow).cells(iCol).style.borderRight="1px solid #000000";
}
}
//設置頭行樣式
for(iCol=0;iCol<iColCount;iCol++)
{
element.rows(0).cells(iCol).style.backgroundColor=rgbFirstRowBgColor;
}
//設置頭列樣式
for(iRow=1;iRow<iRowCount;iRow++)
{
element.rows(iRow).cells(0).style.backgroundColor=rgbFirstColBgColor;
}
//設置編輯單元格
for(mIndex=1;mIndex<iRowCount;mIndex++)
{
for(nIndex=1;nIndex<iColCount;nIndex++)
{
var vText=element.rows(mIndex).cells(nIndex).innerHTML;
element.rows(mIndex).cells(nIndex).innerHTML="<div contentEditable=false>"+vText+"</div>";
element.rows(mIndex).cells(nIndex).children[0].attachEvent("onclick",onEditTrue);
element.rows(mIndex).cells(nIndex).children[0].attachEvent("onblur",onEditFalse);
}
}
//綁定列事件
for(iCol=1;iCol<iColCount;iCol++)
{
element.rows(0).cells(iCol).attachEvent("onmouseup",onColHeaderMouseDown);
}
//綁定行事件
for(iRow=1;iRow<iRowCount;iRow++)
{
element.rows(iRow).attachEvent("onmouseup",onRowHeaderMouseDown);
}
//綁定事件方法
element.attachEvent("onmousedown",onMouseDown);
element.attachEvent("onmousemove",onMouseMove);
element.attachEvent("onmouseup",onMouseUp);
element.attachEvent("onselectstart",onSelectStart);
}
//按下列
function onColHeaderMouseDown()
{
iCurColIndex=window.event.srcElement.cellIndex;
onColHeaderMouseDownColor(iCurColIndex);
}
//按下行
function onRowHeaderMouseDown()
{
iCurRowIndex=window.event.srcElement.parentElement.rowIndex;
onRowHeaderMouseDownColor(iCurRowIndex);
}
//啟動編輯單元格
function onEditTrue()
{
var vEditObject=window.event.srcElement;
vEditObject.contentEditable=true;
vEditObject.runtimeStyle.backgroundColor=rgbCurEditBgColor;
}
//禁止編輯單元格
function onEditFalse()
{
var vEditObject=window.event.srcElement;
vEditObject.contentEditable=false;
vEditObject.runtimeStyle.backgroundColor="transparent";
}
//Grid鼠標按下
function onMouseDown()
{
if(window.event.srcElement.tagName.toUpperCase()=="TD")
{
if(window.event.srcElement.cellIndex==0)
{
bIsDragRow=true;
iDragHistoryRowIndex=window.event.srcElement.parentElement.rowIndex;
}
if(window.event.srcElement.parentElement.rowIndex==0)
{
bIsDragCol=true;
iDragHistoryColIndex=window.event.srcElement.cellIndex;
}
}
}
//Grid鼠標移動
function onMouseMove()
{
if(bIsDragRow==true)
{
//拖動行模擬層處理.
}
if(bIsDragCol==true)
{
//拖動列模擬層處理.
}
}
//Grid鼠標抬起
function onMouseUp()
{
if(bIsDragRow==true)
{
if(window.event.srcElement.tagName.toUpperCase()=="TD")
{
if(window.event.srcElement.cellIndex==0)
{
iDragCurrentRowIndex=window.event.srcElement.parentElement.rowIndex;
if(iDragHistoryRowIndex!=0&&iDragCurrentRowIndex!=0)
{
moveRow(iDragHistoryRowIndex,iDragCurrentRowIndex);
}
}
}
}
if(bIsDragCol==true)
{
if(window.event.srcElement.tagName.toUpperCase()=="TD")
{
if(window.event.srcElement.parentElement.rowIndex==0)
{
iDragCurrentColIndex=window.event.srcElement.cellIndex;
if(iDragHistoryColIndex!=0&&iDragCurrentColIndex!=0)
{
moveCol(iDragHistoryColIndex,iDragCurrentColIndex);
}
}
}
}
bIsDragRow=false;
bIsDragCol=false;
}
//Grid鼠標移出
function onMouseOut()
{
if(bIsDragRow==true)
{
bIsDragRow=false;
}
if(bIsDragCol==true)
{
bIsDragCol=false;
}
}
//Grid選擇開始
function onSelectStart()
{
return false;
}
//庫
//移動行
function moveRow(iFromIndex,iToIndex)
{
var strFromArray=new Array(iColCount);
var strToArray=new Array(iColCount);
for(mIndex=0;mIndex<iColCount;mIndex++)
{
strFromArray[mIndex]=element.rows(iFromIndex).cells(mIndex).innerHTML;
strToArray[mIndex]=element.rows(iToIndex).cells(mIndex).innerHTML;
}
for(nIndex=0;nIndex<iColCount;nIndex++)
{
element.rows(iFromIndex).cells(nIndex).innerHTML=strToArray[nIndex];
element.rows(iToIndex).cells(nIndex).innerHTML=strFromArray[nIndex];
}
onRowHeaderMouseDownColor(iToIndex);
cellAttachEvent();
}
//移動列
function moveCol(iFromIndex,iToIndex)
{
var strFromArray=new Array(iRowCount);
var strToArray=new Array(iRowCount);
for(mIndex=0;mIndex<iRowCount;mIndex++)
{
strFromArray[mIndex]=element.rows(mIndex).cells(iFromIndex).innerHTML;
strToArray[mIndex]=element.rows(mIndex).cells(iToIndex).innerHTML;
}
for(nIndex=0;nIndex<iRowCount;nIndex++)
{
element.rows(nIndex).cells(iFromIndex).innerHTML=strToArray[nIndex];
element.rows(nIndex).cells(iToIndex).innerHTML=strFromArray[nIndex];
}
onColHeaderMouseDownColor(iToIndex);
cellAttachEvent();
}
//行按下變化
function onRowHeaderMouseDownColor(pCurRowIndex)
{
clearClient();
for(kIndex=1;kIndex<iColCount;kIndex++)
{
element.rows(pCurRowIndex).cells(kIndex).bgColor=rgbCurRowBgColor;
}
}
//列按下變化
function onColHeaderMouseDownColor(pCurColIndex)
{
clearClient();
for(kIndex=1;kIndex<iRowCount;kIndex++)
{
element.rows(kIndex).cells(pCurColIndex).bgColor=rgbCurColBgColor;
}
}
//清除客戶區
function clearClient()
{
for(mIndex=1;mIndex<iRowCount;mIndex++)
{
for(nIndex=1;nIndex<iColCount;nIndex++)
{
element.rows(mIndex).cells(nIndex).bgColor="transparent";
}
}
}
//單元格事件綁定
function cellAttachEvent()
{
for(mIndex=1;mIndex<iRowCount;mIndex++)
{
for(nIndex=1;nIndex<iColCount;nIndex++)
{
element.rows(mIndex).cells(nIndex).children[0].attachEvent("onclick",onEditTrue);
element.rows(mIndex).cells(nIndex).children[0].attachEvent("onblur",onEditFalse);
}
}
}
</script>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 黄网站在线观 | 亚洲精品欧美二区三区中文字幕 | 久久久久中文字幕 | 成人免费观看在线视频 | 在线看一区二区三区 | 国产四区| 黄色大片免费网站 | 国产黄色录像片 | 精品一区二区三区欧美 | 91懂色 | 日韩黄色av网站 | 亚洲一区成人 | 最新av网址在线观看 | 黄视频免费在线 | 特级黄色一级毛片 | 日本视频在线播放 | 一级大黄毛片 | 午夜小网站 | 欧美黄色一级片视频 | 国产精品三级a三级三级午夜 | 国产一级一区 | japanese javhd| 久久精品视频8 | 国产成人综合在线观看 | 久国产 | 202z中文字幕第一页 | 国产成年人视频网站 | 亚洲精品aa| 高清一区二区在线观看 | 国产女做a爱免费视频 | 中文字幕一区二区三区四区 | 一级黄色毛片免费 | 视频一区二区中文字幕 | 又黄又爽又色无遮挡免费 | 把娇妻调教成暴露狂 | 亚洲婷婷日日综合婷婷噜噜噜 | 日本在线视频免费 | 国产精品99久久久久久久女警 | 性片免费看 | 欧美性成人 | 精品国产一区二区三区久久久蜜月 |