📄 xtdbgrid.htc
字号:
function splitEnd(){// 拖动表头结束
if (allowResizeModle.toString() == "false") return ;
if(objSplitBar == null) return;
var oCurTitleDiv = objSplitBar.parentElement.parentElement.previousSibling.children(0);// 当前点击的div
objSplitBar.releaseCapture(); //解除鼠标捕获
objSplitBar.detachEvent("onmousemove",split); //解除mousemove事件的绑定
if(objSplitBar.children(0))
objSplitBar.children(0).removeNode(true); //移除split line
objSplitBar = null;
vMoveLen = window.event.clientX - vMouseStart; //移动的距离
vCellIndex = oCurTitleDiv.parentNode.cellIndex; //当前点击 DIV 所在 TD 的索引号
if(vMoveLen!=0){
oCurTitleDiv.style.pixelWidth = oCurTitleDiv.offsetWidth + vMoveLen;
if(oCurTitleDiv.offsetWidth < oCurTitleDiv.MinWidth - 4) //取最小宽度
oCurTitleDiv.style.pixelWidth = oCurTitleDiv.MinWidth - 4;
if(oCurTitleDiv.offsetWidth > oCurTitleDiv.MaxWidth - 4) //取最大宽度
oCurTitleDiv.style.pixelWidth = oCurTitleDiv.MaxWidth - 4;
if(oTBodyTable && oTBodyTable.rows(0)!=null)
oTBodyTable.rows(0).cells(vCellIndex).childNodes(0).style.pixelWidth = oCurTitleDiv.style.pixelWidth;
}
vMouseStart = null;
oCurTitleDiv = null;
//adjustGridWidth(1); //调整title body table三者宽度
evtOnDrag.fire(); //激发拖动事件
}
function adjustBodyWidth(){ //调整三部分宽度,加上偏移量,并产生校调晃动
if(oTitle==null || oTBody==null) return;
if(hasTitle.toString() == "true") oTBody.style.pixelWidth = oTBodyTable.offsetWidth + 1;
else oTBody.style.pixelWidth = vWidth - 16; //如果没有表头就不能根据data table来确定data div的宽度
oTitle.style.pixelWidth = oTBodyTable.offsetWidth + 1;
}
function selectScrollTrack(){ //跟随鼠标滚动选择
var objSrc = window.event.srcElement;
for(var i = 0; i < 3; i++){
if(objSrc.tagName.toLowerCase() == "tr") break;
objSrc = objSrc.parentElement;
}
if(i == 3) return;
if(objSrc.rowIndex == 2) return;
selected(objSrc,true); //选中当前行
objScrollTrack = objSrc;
}
function cancelSelectScrollTrack(){ //取消鼠标跟随中的前次选择
if(objScrollTrack) selected(objScrollTrack,false); //取消前次选中
}
function clickTable(){//点击DBGrid组件cell时处理事件
//
//debugger;
var oSrc,i;
var vRowTemp;
var n;
var objParentTR;
var boolInArr = false;
if(funVerifyInputWhenBlur() == -1){
return(-1);
}
selectTable(false); //取消前次的table选择
oSrc = window.event.srcElement;
if(oSrc.tagName == "INPUT" && oSrc.type == "checkbox"){
objParentTR = oSrc;
for(var i=0;i < 4;i++){
if(objParentTR.tagName == "TR"){
break;
}else{
objParentTR = objParentTR.parentElement;
}
}
if(i==4) return;//没有找到相应的行
if(oSrc.checked == true){//如果checkBox的状态为选中
n = arrCheckedRow.length;
for(var i = 0; i < n; i++){//判断该checkBox所在行的__rowid是否已经被加到了arrCheckRow数组中
if(arrCheckedRow[i] == objParentTR.__rowid){
boolInArr = true;
break;
}//End of if
}//End of for
//alert("true add " + boolInArr);
if(!boolInArr)//没有加进去
arrCheckedRow.push(objParentTR.__rowid);
}else{//如果checkBox的状态为未选中
n = arrCheckedRow.length;
for(var i = 0; i < n; i++){
if(arrCheckedRow[i] == objParentTR.__rowid){//将该行的__rowid从arrcheckRow数组中删除
boolInArr = true;
arrCheckedRow.splice(i,1);
break;
}//End of if
}//End of for
}
}//End of if
for(i = 0; i < 2; i++){ //取得点击的td对象
if(oSrc.tagName.toLowerCase() == "td") break;
oSrc = oSrc.parentElement;
}
if(i == 2) return; //说明没有找到td元素,返回
vTableRow = oSrc.parentElement.rowIndex;//行
vTableCol = oSrc.cellIndex;//列
//alert("tableRow=" + tableRow + "\ntableCol=" + tableCol);
if(vSelectionMode == "row" && vTableCol < 0) vTableCol = 1;
selectTable(true); //选择当前点击的cell或者row
showRC();
evtClickCell.fire();
//window.status = "所有选中的checkBox数量为:" + arrCheckedRow.length;
}
function showRC(){//显示当前cell的行列坐标
var r;
var c;
//
if(hasController=="true" && oControl!=null){
oControl.curRowCaption.style.visibility = "visible";
oControl.curColCaption.style.visibility = "visible";
r = parseInt(tableRow) + 1;
c = parseInt(tableCol) + 1;
if(r>=0 && c>=0){
oControl.curRow.value = r;
oControl.curCol.value = c;
}
}
hideInput();
}
function selectTable(bIsSelected){ //选择或者取消由 tableCol 和 tableRow 指定的单元格或其所在的表行(包括fixed col和对应的title cell)
try{
var collCells;
if(vTableRow < 0 || vTableCol < 0) return; //如果尚未在表格中使用鼠标选择则不能进行 key选择
collCells = oTBodyTable.rows(vTableRow).cells;
if(vSelectionMode == "cell"){ //单元格选择
selected(collCells(vTableCol),bIsSelected);
}else{ //行选
for(i = 0; i < collCells.length; i++){
selected(collCells(i),bIsSelected);
}
}
}catch(e){}
}
function selected(objSrc,bIsSelected){ //选中某一对象即改变其背景和前景色,参数为对象、是否选中标志
try{
if(bIsSelected){
objSrc.runtimeStyle.color = selectForeColor;
objSrc.runtimeStyle.backgroundColor = selectBgColor;
}else{
with(objSrc.runtimeStyle){
color = "";
backgroundColor = "";
}
}
}catch(e){
//错误丢弃
}
}
function clickTitle(){ //点击标题行
var intCurCellIndex = 0;
//var vAllowSort = oTitleTable.rows(0).cells(event.srcElement.parentElement.cellIndex).children(0).getAttribute("allowSort");
if(oEditor && oEditor.style.display != "none") return;
var vAllowSort = event.srcElement.allowSort;
if(vAllowSort=="false") return;//该列不允许排序
var oSrc = null;
oSrc = window.event.srcElement;
for(var i = 0; i < 3; i++){
if(oSrc.tagName.toLowerCase() == "div" && oSrc.getAttribute("rpropname")){
intCurCellIndex = oSrc.parentElement.cellIndex;
break;
}
oSrc = oSrc.parentElement;
}
if(i == 3) return;//没有找到div
var vOrder = null;//排序规则
if(oSrc == oSortBtn.parentElement){//如果点击的是同一列
if(oSortBtn.children(0).style.flip == "y"){
oSortBtn.children(0).style.flip = "";
vOrder = "ascending";
}else{
oSortBtn.children(0).style.flip = "y";
vOrder = "descending";
}
}else{//点击的不是同一列
oSortBtn.children(0).style.flip = "";
oSortBtn = oSrc.appendChild(oSortBtn);
vOrder = "ascending";
}
sort(intCurCellIndex,oSrc.getAttribute("rpropname"),vOrder); //开始排序
}
function sort(curCellIndex,colName,order){ //对指定列按指点规则进行排序
//debugger;
var vXslt;
var strDataXML;
var objNode;
var vFirstRowCellText = "";
if(!oTBodyTable.rows(0)) return;
vFirstRowCellText = oTBodyTable.rows(0).cells(curCellIndex).innerText;//数据表第一行当前列的内容
if(isNaN(vFirstRowCellText) || vFirstRowCellText == ""){//不是数字列
vXslt = "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:output method='xml' omit-xml-declaration='no' encoding='gb2312' version='1.0' indent='yes'/><xsl:template match='/'><root><xsl:for-each select='*/*'><xsl:sort select='@" + colName + "' order='" + order + "'/><xsl:copy-of select='.'/><xsl:copy-of select='@*'/></xsl:for-each></root></xsl:template></xsl:stylesheet>";
}else{//数字列
vXslt = "<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:output method='xml' omit-xml-declaration='no' encoding='gb2312' version='1.0' indent='yes'/><xsl:template match='/'><root><xsl:for-each select='*/*'><xsl:sort select='format-number(@" + colName + ",\"00000.00000\")' order='" + order + "'/><xsl:copy-of select='.'/><xsl:copy-of select='@*'/></xsl:for-each></root></xsl:template></xsl:stylesheet>";
}
strDataXML = oCopyDataXML.xml.replace(/xmlns:fo=\"\"/g, "");
objNode = oCopyDataXML.removeChild(oCopyDataXML.childNodes(0));
objNode = null;
oCopyDataXML = inputXML(__objGlobalCommonInst.transformXML(strDataXML,vXslt)); //xml依据排序转换
fillInTable(); //填充表格
if(hasPageFooter == "true")
viewPageFooter();
}
function fillInTable(){ //生成DBGrid组件数据表,用XML数据填充
var oXSLT = null;//XSLT对象
var vXslt = null;//xslt字符串
var vFirstRow = "";//第一行xslt
var vOtherRow = "";//其它行xslt
var vRowTemp = ""; //临时xslt
var vFixedCol = "";
var strRowIDS = "";//用来保存通过checkBox选中行的__rowid所组成的字符串
var tmpStr = "";
if(!oTitleXML) return;
if(oTBody) oTBody.removeNode(true);//删除原有数据表容器
oTBody = null;
oTBody = element.document.createElement("<div class='phms_grid_oTBody'></div>");
if(oTBodyTable) oTBodyTable.removeNode(true); //删除原有表格
oTBodyTable = null;
refresh();
var visibleColsList = oTitleXML.selectNodes("/*/*[not(@visible = 'false')]");
//构造xslt
vXslt = "<xsl:stylesheet version = '1.0' xmlns:xsl = 'http://www.w3.org/1999/XSL/Transform'><xsl:output method = 'html'/><xsl:template match = '/'><table class='phms_grid_oTBodyTable' bgcolor='"
+ dataBgColor + "' border = '0' cellspacing = '1' cellpadding = '0'><xsl:for-each select = '*/*'><xsl:choose><xsl:when test='position() = " + getFirstPosition() + "'><tr bgcolor='"
+ dataBgColor + "' height='18'><xsl:attribute name='__rowid'><xsl:value-of select='@__rowid'/></xsl:attribute>";
for(var i = 0; i < visibleColsList.length; i++){ //获取列值
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -