⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flexgrid.htc

📁 HTC,demo WEB用于。 超大型
💻 HTC
📖 第 1 页 / 共 5 页
字号:
			        objLeafElement.parentElement.removeChild(objLeafElement);
			      if(objLeafElement.parentNode)
			        objLeafElement.parentNode.removeChild(objLeafElement);
			      objLeafElement = null;
			    }//End of if
			  }//End of for

			}//End of clear

		  function lostFocus(){//焦点消失/
			  window.document.attachEvent("onmousedown",clickDocument);
		  }

		  function clickDocument(){//点击FlexGrid以外的Document对象时隐藏当前活动的输入框

		    var objSrc = window.event.srcElement;
		    if(element.contains(objSrc)) return;

          window.document.detachEvent("onmousedown",clickDocument);
          try{
            oTBodyTable.rows(vPreviousRow).cells(vPreviousCol).style.color = "#000000";
          }catch(e){

          }
        }

		  function keydownTBodyTable(){//移动光标键进行cell或tr之间的移动

			  var vKeyCode = window.event.keyCode;

			  if(vKeyCode > 40 || vKeyCode < 37) return;
			  if(vTableRow < 0 || vTableCol < 0) return; //当没有选中某一个cell时不能使用key 编辑
			  switch(vKeyCode){
				  case 37:	//左
					  if(vSelectionMode != "row") selectTable(false); //如果是行选则左右方向键不改变外观,如果是单元格选择则恢复上次选择的单元格的样式
					  if(vTableCol ==  0) tableCol = oTBodyTable.rows(0).cells.length - 1; //到达表格左端则返回右端
					  else vTableCol--;
					  if(vSelectionMode != "row") selectTable(true);
					  scrollRowToView(vTableRow,vTableCol);//移动当前行到可视范围
					  showRC();
					  evtClickCell.fire();
					  break;
				  case 38:	//上
					  selectTable(false);
					  if(vTableRow ==  0) tableRow = oTBodyTable.rows.length - 1; //到达顶端返回底端
					  else vTableRow--;
					  selectTable(true);
					  scrollRowToView(vTableRow); //移动当前行到可视范围
					  showRC();
					  evtClickCell.fire();
					  break;
				  case 39:	//右
					  if(vSelectionMode != "row") selectTable(false); // //恢复上次选择的单元格的样式
					  if(vTableCol == oTBodyTable.rows(0).cells.length - 1) vTableCol = 0; //到达右端返回左端非fixedCols的第一列
					  else vTableCol++;
					  if(vSelectionMode != "row") selectTable(true); //选中经过key arrow键选中的cell或者row;
					  scrollRowToView(vTableRow,vTableCol);//移动当前行到可视范围
					  showRC();
					  evtClickCell.fire();
					  break;
				  case 40:	//下
					  selectTable(false); //恢复上次选择的单元格的样式
					  if(vTableRow ==  oTBodyTable.rows.length - 1) tableRow = 0; //到达底端返回顶端
					  else vTableRow++;
					  selectTable(true);
					  scrollRowToView(vTableRow); //移动当前行到可视范围
					  showRC();
					  evtClickCell.fire();
					  break;
			  }
			  window.event.returnValue = false;
		  }


		  function scrollRowToView(argRow,argCol){ //将当前行或者单元格滚动到table div的可视范围内(指定行未指定列可以滚动指定行,两者都指定才能滚动单元格,argCol指的是单元格的tableCol)
			  var objRow,objCell;
			  var vTemp;

			  if(typeof(argRow) == "undefined" || argRow == -1) return; //至少需要argRow参数

			  objRow = oTBodyTable.rows(argRow); //要移动的row
			  if(objRow==null) return;
			  vTemp = objRow.offsetTop - oTBody.scrollTop; //行顶部与body div的顶部之间的距离

			  if(vTemp < 0){ //说明该行被藏于body div的上部
				  oTBody.scrollTop += vTemp;
			  }else{
				  vTemp = objRow.offsetTop + objRow.offsetHeight - (oTBody.scrollTop + oTBody.offsetHeight); //行底部与body div底部之间的距离
				  if(vTemp > 0){ //说明该行藏于body div的下部
					  oTBody.scrollTop += vTemp + 16;//16为div滚动条的高度
				  }
			  }

			  if(typeof(argCol) == "undefined") return; //两参数都指定才能给cell定位
			  objCell = oTBodyTable.rows(argRow).cells(argCol); //要移动的cell
			  if(objCell==null) return;
			  vTemp = objCell.offsetLeft - oTBody.scrollLeft; //cell左侧与body div的顶部之间的距离
			  if(vTemp < 0){ //说明该行被藏于panel div的左侧
					  if(argCol == 0) oTBody.scrollLeft = 0;
					  else oTBody.scrollLeft += vTemp;
			  }else{
					  vTemp = objCell.offsetLeft + objCell.offsetWidth - (oTBody.scrollLeft + oTBody.offsetWidth); //cell右侧与Panel div右部之间的距离
					  if(vTemp > 0){ //说明该行藏于panel div的右侧
						  oTBody.scrollLeft += vTemp + 16;//16为div滚动条的宽度
					  }
			  }
		  }


			  function initialize(){ //FlexGrid组件初始化操作
					initGlobalCommon();
				  vTableCol = -1;
				  vTableRow = -1;
				  getCopyDataXML();//获得增加了clientAct="k"属性的oCopyDataXML拷贝oCopyDataXML对象
				  createTitle(); //创建oTitleTable
				  oDataTable = window.document.createElement("<div/>");//建立数据表格的容器
				  oDataTable = element.appendChild(oDataTable);
				  oDataTable.oncontextmenu = function(){event.returnValue = false;};
				  fillInTable(); //用XML数据填充表并显示
				  if(hasController=="true" && oControl==null)
				    viewController();
				  refresh();//FlexGrid组件位置样式初始化

				  if(oTitle && oTBody){
					  oSortBtn = window.document.createElement("<span class='phms_sortBtnSpan'></span>");
					  oSortBtn.innerHTML = "<v:polyline points='0,6 4,0 8,6 0,6' class='phms_sortBtn' fillcolor='black' strokcolor='red'/><?xml:namespace prefix='v' urn='schemas-microsoft-com:vml'/>";
				  }
				  element.runtimeStyle.visibility = "visible";
				  if(oControl!=null){
					  oControl.firstPage.disabled = true;
					  oControl.previousPage.disabled = true;
					  if(intRows <= oPageSize){//如果记录总数小于每页显示记录数则使下一页和最后一页按钮也失效
					oControl.nextPage.disabled = true;
					oControl.lastPage.disabled = true;
					}
				  }
				  if(oDataXML!=null) objDeletedXMLFragement = inputXML();
				  ifFirst = false;
			  }

			  function initGlobalCommon(){//初始化__objGlobalCommonInst
                if(!element.document.parentWindow.__objGlobalCommonInst){//如果还没有初始化
                    var oWindow;
                    oWindow = element.document.parentWindow;
                    oWindow.__objGlobalCommonInst = oWindow.parent.__objGlobalCommonInst;
                    __objGlobalCommonInst = oWindow.__objGlobalCommonInst;
                    if(!__objGlobalCommonInst){
                        __objGlobalCommonInst = oWindow.dialogArguments.__objGlobalCommonInst;
                    }
                    }
                }

			  function getCell(argRow,argCol){ //根据指定的表格行列值得到指定单元格的内容
				  if(typeof(argRow) == "undefined") argRow = tableRow;
				  if(typeof(argCol) == "undefined") argCol = tableCol;

				  var vRow = parseInt(argRow);
				  var vCol = parseInt(argCol); //传递的应该是相对地址而不是table的绝对地址
				  if(vRow > oTBodyTable.rows.length - 1 || vRow < 0) return null;
				  if(vCol > oTBodyTable.rows(0).cells.length - 1 || vCol < 0) return null;

				  return oTBodyTable.rows(vRow).cells(vCol);
			  }

		function viewController(){//分页控制器
          var conTrolStr = "";

          oControl = window.document.createElement("<div></div>");
          oControl.oncontextmenu = function(){event.returnValue = false;};
          oControl.runtimeStyle.width = width;
          oControl = element.appendChild(oControl);

          conTrolStr += "<div class='phms_flexGrid_controller' align='right'>";//div容器

          conTrolStr += "<input style='position:absolute;background:#ffffff;top:4;right:40px;height:14;width:30;border:1px solid #A6C4E1;color:#4F789D;'/>";//当前页->[0]
          conTrolStr += "<input style='position:absolute;background:#ffffff;top:4;right:212;height:14;width:28;border:1px solid #A6C4E1;color:#4F789D;'/>";//每页显示记录数->[1]
          /////////////////////////////
          conTrolStr += "<span style='position:absolute;color:#4F789D;top:5;right:360;'>行:</span>";//标签:行:->[2]
          conTrolStr += "<span style='position:absolute;color:#4F789D;top:5;right:310;'>列:</span>";//标签:列:->[3]
          conTrolStr += "<span style='position:absolute;color:#4F789D;top:5;right:242;'>(本页</span>";//标签:(每页->[4]
          conTrolStr += "<span style='position:absolute;color:#4F789D;top:5;right:180;'>条&nbsp;共</span>";//标签:条&nbsp;&nbsp;共->[5]
          conTrolStr += "<span style='position:absolute;color:#4F789D;top:5;right:120;'>条)</span>";//标签:条)->[6]
          ////////////////////////////////
          conTrolStr += "<input style='position:absolute;background:white;top:4;right:141px;width:36;height:16;border:0px solid #A6C4E1;text-align:center;font-size:10;font-family:arial;color:#4F789D;' readonly/>";//记录总数->[7]
          conTrolStr += "<input style='position:absolute;right:330;top:4;height:16;width:30;border:0px solid #A6C4E1;color:#4F789D;font-size:10;font-family:arial;' readonly/>";//当前行坐标->[8]
          conTrolStr += "<input style='position:absolute;right:280;top:4;height:16;width:30;border:0px solid #A6C4E1;color:#4F789D;font-size:10;font-family:arial;' readonly/>";//当前列坐标->[9]

          //导航按钮
          conTrolStr += "<v:polyline points='0,14 0,0 0,7 8,0 8,14,0,7 0,14' style='position:absolute;top:3;right:95;' strokecolor='#7B9EBD' fillcolor='#7B9EBD' title='第一页'/>";//首页->[10]
          conTrolStr += "<v:polyline points='0,7 7,0 7,14 0,7' style='position:absolute;top:3;right:80px;' strokecolor='#7B9EBD' title='上一页'/>";//上一页->[11]
          conTrolStr += "<v:polyline points='7,7 0,0 0,14 7,7' style='position:absolute;top:3;right:25px;' strokecolor='#7B9EBD' title='下一页'/>";//下一页->[12]
          conTrolStr += "<v:polyline points='7,14 7,0 7,7 0,0 0,14 7,7 7,14' style='position:absolute;top:3;right:10px' strokecolor='#7B9EBD' fillcolor='#7B9EBD' title='最后一页'/>";//尾页->[13]
          /////////打印//////////->[14]
          conTrolStr += "<v:group style='position:absolute;left:10;top:0px;height:16px;width:13;' coordsize='14,16'>";
          conTrolStr += "<v:roundrect arcsize='6554f' strokeweight='.75pt' style='position:absolute;top:3;right:500;width:70;height:16;cursor:hand' strokecolor='#4F789D' coordsize='21600,21600' title='打印'></v:roundrect>";
          conTrolStr += "<v:textbox style='position:absolute;top:4;right:8;color:#4F789D;font-family:arial black;font-size:7pt;cursor:hand;zIndex:0' title='导出数据'>导出数据</v:textbox>";
          conTrolStr += "</v:group>";


          conTrolStr += "</div>";

          oControl.insertAdjacentHTML("afterBegin",conTrolStr);

          oTemp = oControl.children(0);//div
          oControl.curPage = oTemp.children(0);//当前页
          oControl.pageSize = oTemp.children(1);//每页显示记录数
          oControl.recordCount = oTemp.children(7);//记录总数
          oControl.firstPage = oTemp.children(10);//首页
          oControl.previousPage = oTemp.children(11);//上一页
          oControl.nextPage = oTemp.children(12);//下一页
          oControl.lastPage = oTemp.children(13);//尾页
          oControl.print = oTemp.children(14);//打印
          oControl.curRow = oTemp.children(8);//当前行
          oControl.curCol = oTemp.children(9);//当前列
          oControl.curRowCaption = oTemp.children(2);//行标签
          oControl.curColCaption = oTemp.children(3);//列标签
          oControl.curRowCaption.style.visibility = "hidden";
          oControl.curColCaption.style.visibility = "hidden";

          if(hasPrintButton == "false"){//是否显示打印按钮
            oTemp.removeChild(oControl.print);
          }else{
            oControl.print.onclick = getReportFormsPrintInfo;
          }


				  oTemp.style.background = controllerBgColor;
				  oControl.recordCount.style.background = controllerBgColor;
				  oControl.curRow.style.background = controllerBgColor;
  				oControl.curCol.style.background = controllerBgColor;
				  oControl.firstPage.onclick = moveFirst;
				  oControl.previousPage.onclick = movePrevious;
				  oControl.nextPage.onclick = moveNext;
				  oControl.lastPage.onclick = moveLast;
				  //页面加载时需要初始化的一些参数
				  if(intRows <=oPageSize){
            oControl.pageSize.value = intRows;
          }else{
            oControl.pageSize.value = oPageSize;//每页显示记录数
          }
				  oControl.curPage.value = curPage;//当前页
				  oControl.curPage.onkeydown = gotoPage;//当输入页号后回车后转到相关页面
				  oControl.curPage.style.textAlign = "center";
		          oControl.curPage.style.fontFamily = "arial";
				  oControl.curPage.style.fontSize = "7pt";
				  oControl.pageSize.onkeydown = refreshPageSize;//当输入pageSize后回车后重画页面
				  oControl.pageSize.style.textAlign = "center";
				  oControl.pageSize.style.fontFamily = "arial";
				  oControl.pageSize.style.fontSize = "7pt";
				  oControl.recordCount.value = intRows; //记录总数
			  }


			  function PrintOut(){//打印表格
            var oTitleXMLCopy;
            var objNode;
            var objNodeSwap;
            var vTitleColXML;
            var vDataColXML;
            var vUniteXML;
            var responseXml;
            var strURI;


            oTitleXMLCopy = oTitleXML.cloneNode(true);
            for(var i = 0; i < oTitleXMLCopy.childNodes(0).childNodes.length; i++){
              objNode = oTitleXMLCopy.childNodes(0).childNodes(i);
              while(objNode.childNodes.length > 0){
                objNodeSwap = objNode.removeChild(objNode.childNodes(0));
                objNodeSwap = null;
              }
            }

            vTitleColXML = "<titleXML>" + ("<" + oTitleXMLCopy.childNodes(0).xml + ">").replace("<<root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">","").replace("<<root>","").replace("</root>>","") + "</titleXML>";
            vDataColXML = "<dataXML>" + ("<" + oCopyDataXML .childNodes(0).xml + ">").replace("<<root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">","").

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -