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

📄 extenddbgrid.htc

📁 HTC,demo WEB用于。 超大型
💻 HTC
📖 第 1 页 / 共 5 页
字号:
            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(); //填充表格

        }


        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 = "";
          var intCurRecordCountNumber;
          
          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() = 1'><tr bgcolor='" 
          + dataBgColor + "' height='18'><xsl:attribute name='__rowid'><xsl:value-of select='@__rowid'/></xsl:attribute>";

          for(var i = 0; i < visibleColsList.length; i++){ //获取列值
            var rowCnt = "<xsl:value-of select='position()'/>";//行位置         
  
              if(visibleColsList(i).getAttribute("edittype")=="c"){//如果该列为checkBox列
                  vRowTemp = "<input id='ichk' type='checkbox' class='phms_r_c'></input>";                
              }else{
                  vRowTemp = "";
              }//End of if edittype = "c"
              
              if(visibleColsList(i).getAttribute("calculateCol")){
                vRowTemp += "<xsl:value-of select='" + visibleColsList(i).getAttribute("calculateCol") + "'/>";                     
              }else{
                vRowTemp += "<xsl:value-of select='@" + visibleColsList(i).getAttribute("rpropname") + "'/>";                     
              }
              
              vFirstRow += "<td align='center'>" + "<div class='phms_grid_oFirstLineDiv'>" + vRowTemp + "</div></td>";
              vOtherRow += "<td align='center'>" + vRowTemp + "</td>";
          }

          if(parseInt(hasFixedCol) == 1){ //生成fixed col xslt
            vFixedCol = "<td class='phms_grid_index' align='" +  fixedColAlign + "' style='color:" + fixedColForeColor + "; background:" + fixedColBGColor + ";";
            vFirstRow = vFixedCol + "'><div class = 'phms_grid_indexDiv'><font face='arial' size='1'><xsl:value-of select='position()'/></font></div></td>" + vFirstRow;
            vOtherRow = vFixedCol + "'><font face='arial' size='1'>" +  rowCnt + "</font></td>" + vOtherRow;
          }
         // 
          if(oCopyDataXML && oCopyDataXML.xml && oCopyDataXML.childNodes(0).childNodes.length <= 1){
            vXslt += "<xsl:attribute name='bgcolor'>" + oddTRColor + "</xsl:attribute>" + vFirstRow + "</tr></xsl:when><xsl:otherwise><xsl:choose><xsl:when test='position() &gt;1'><tr><xsl:attribute name='__rowid'><xsl:value-of select='@__rowid'/></xsl:attribute><xsl:if test='position() mod 2 = 0'><xsl:attribute name='bgcolor'>" 
            + evenTRColor + "</xsl:attribute></xsl:if><xsl:if test='position() mod 2 != 0'><xsl:attribute name='bgcolor'>" + oddTRColor + "</xsl:attribute></xsl:if>" + vOtherRow +  "</tr></xsl:when></xsl:choose></xsl:otherwise></xsl:choose></xsl:for-each></table></xsl:template></xsl:stylesheet>";
          }else{
            vXslt += "<xsl:attribute name='bgcolor'>" + oddTRColor + "</xsl:attribute>" + vFirstRow + "</tr></xsl:when><xsl:otherwise><xsl:choose><xsl:when test='position() &gt;=1 and position() &lt;=" + oPageSize + "'><tr><xsl:attribute name='__rowid'><xsl:value-of select='@__rowid'/></xsl:attribute><xsl:if test='position() mod 2 = 0'><xsl:attribute name='bgcolor'>" 
            + evenTRColor + "</xsl:attribute></xsl:if><xsl:if test='position() mod 2 != 0'><xsl:attribute name='bgcolor'>" + oddTRColor + "</xsl:attribute></xsl:if>" + vOtherRow +  "</tr></xsl:when></xsl:choose></xsl:otherwise></xsl:choose></xsl:for-each></table></xsl:template></xsl:stylesheet>";
          }   
        
          if(oCopyDataXML == null) return; 
          //
          tmpStr = oCopyDataXML.xml;
          tmpStr = tmpStr.replace(/xmlns:fo=\"\"/g,"").replace(/1900-01-01/g,"");

          oTBody.insertAdjacentHTML("afterBegin",__objGlobalCommonInst.transformXML(tmpStr,vXslt)); //插入转换后的HTML
          //
          oTBodyTable = oTBody.childNodes(0); //数据表格对象
          oTBodyTable.onmousedown = clickTable;
          oTBodyTable.ondblclick =dbclickCell;

          oTBody = oDataTable.insertAdjacentElement("beforeEnd",oTBody); 
          oTBody.onscroll = scrollIDL; //左右滚动事件绑定           
          adjustGridWidth(0);//协调表头和列的宽度一致     
         //////////////////////////////////////
         /*
			if(oControl){
			intCurRecordCountNumber = getCurRecordsCount();//得到返回记录数
			
			oControl.curPage.value = 1;
			curPage = 1;
			if(intCurRecordCountNumber < oPageSize){
				oControl.pageSize.value = intCurRecordCountNumber;
				oControl.startRecordIndex.innerText = 1;
				oControl.endRecordIndex.innerText = intCurRecordCountNumber;
			}else{
				oControl.pageSize.value = oPageSize;
				oControl.startRecordIndex.innerText = 1;
				oControl.endRecordIndex.innerText = oPageSize;
			}
			updatePageControllerData();
			*/
         ///////////////////////////////////////////////
          //
          strRowIDS = "|" + arrCheckedRow.join("|");
          //window.prompt("",strRowIDS);

          if(strRowIDS != "|"){//如果有选中的行
          
            for(var i=0; i<oTBodyTable.rows.length; i++){
              if((strRowIDS.indexOf("|" + oTBodyTable.rows[i].__rowid ) > 0) || (strRowIDS.indexOf(oTBodyTable.rows[i].__rowid + "|") > 0)){
                oTBodyTable.rows[i].all("ichk").checked = true;                
              }           
            }//End of for
            
          }//End of if        
          
      
      }   
                

      function adjustGridWidth(argNum){ //调整title和data的宽度一致
        var vMax; //取title table中较大的div的长度
        var collTitleCells;
        var collDataCells;
        
        if(!oTBodyTable.rows(0)) return(-1);
       // 
//        try{   
          collTitleCells = oTitleTable.rows(0).cells;
          collDataCells = oTBodyTable.rows(0).cells;

          oTitleTable.style.pixelWidth = 1; //让表格收缩到最小才能利用其中的div撑大
          oTBodyTable.style.pixelWidth = 1;
					oTitleTable.rows(0).cells(0).childNodes(0).style.pixelWidth = 1;
        
          for(i = 1; i < collDataCells.length; i++){ //table照着title变化
            vMax = Math.max(collTitleCells(i).childNodes(0).offsetWidth,collDataCells(i).offsetWidth); //取最大值
            collDataCells(i).childNodes(0).style.pixelWidth = vMax; //table's cell 宽度
            collTitleCells(i).childNodes(0).style.pixelWidth = vMax; //title's cell宽度
          }
/*
          for(i = argNum; i < collDataCells.length; i++){//反向调整列宽
            vMax = Math.max(collTitleCells(i).offsetWidth,collDataCells(i).offsetWidth); //取最大值
            collDataCells(i).style.pixelWidth = vMax;
            collTitleCells(i).style.pixelWidth = vMax;
          }
          */
          
          if(hasFixedCol == 1){
						//alert();
						//oTitleTable.rows(0).cells(0).childNodes(0).style.pixelWidth = oTBodyTable.rows(0).cells(0).style.pixelWidth + 14;
						/*
						vMax = Math.max(collTitleCells(0).offsetWidth,collDataCells(0).offsetWidth); //取最大值
            collDataCells(0).childNodes(0).style.pixelWidth = vMax;
						
						if(collTitleCells(0).style.pixelWidth == vMax){
							collTitleCells(0).childNodes(0).style.pixelWidth = vMax - 2;
						}else{
							collTitleCells(0).childNodes(0).style.pixelWidth = vMax + 2;
						}
            */
						//alert();
						//
						collTitleCells(0).childNodes(0).style.pixelWidth = parseInt(collDataCells(0).childNodes(0).offsetWidth) + 2;

					} 

⌨️ 快捷键说明

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