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

📄 ig_webgrid_dom.js

📁 研究怎样通过手写代码来完成自动生成代码
💻 JS
📖 第 1 页 / 共 5 页
字号:
},
"alignDivs",
function(scrollLeft,force)
{
	if(!this.UseFixedHeaders) return;
	var divs=this.scrElem;
	var divf=this.Element.parentNode;
	var isInit=false;
	if(!divs.firstChild.style.width)
	{
		divs.firstChild.style.width=this.Element.offsetWidth + (this.GroupCount==1?this.Indentation:0);
		isInit=true;
	}
	divs.firstChild.style.height=this.Element.offsetHeight;
	this.Element.setAttribute("noOnResize",true);
	var mainGrid=igtbl_getElementById(this.Id+"_main");
	if(!mainGrid.style.width)
		divs.style.width=mainGrid.clientWidth;
	if(!mainGrid.style.height)
		divs.style.height=divf.firstChild.offsetHeight;
	var relOffs=false;
	if(ig_csom.IsIE)
	{
		while(mainGrid && mainGrid.tagName!="BODY" && !relOffs)
		{
			relOffs=mainGrid.style.position!="" && mainGrid.style.position!="static";
			if(!relOffs) mainGrid=mainGrid.parentNode;
		}
	}
	divf.style.left=igtbl_getLeftPos(divs,false,relOffs?mainGrid:null);
	divf.style.top=igtbl_getTopPos(divs,false,relOffs?mainGrid:null);
	this.Element.removeAttribute("noOnResize");
	
	divf.style.width=igtbl_clientWidth(divs);
	divf.style.height=igtbl_clientHeight(divs);
	if(divf.firstChild.style.left=="")
		divf.firstChild.style.left=0;
	if(divf.firstChild.style.top=="")
		divf.firstChild.style.top=0;
	if(!scrollLeft)
		scrollLeft=divs.scrollLeft;
	else
	{
		this.UseFixedHeaders=false;
		divs.scrollLeft=scrollLeft;
		this.UseFixedHeaders=true;
	}
	var doHoriz=false;
	if(this._oldScrollLeftAlign!=scrollLeft)
	{
		this._oldScrollLeftAlign=scrollLeft;
		doHoriz=true;
	}
	if(parseInt(divf.firstChild.style.top,10)!=-divs.scrollTop)
	{
		divf.firstChild.style.top=-divs.scrollTop;
		if(this.StatHeader || this.StateFooter)
			doHoriz=true;
	}
	if(doHoriz || force)
	{
		for(var i=0;i<this.Bands.length;i++)
		{
			var cols=this.Bands[i].Columns;
			var fac=this.Bands[i].firstActiveCell;
			var nfColNo=0,realColNo=fac;
			while(nfColNo<cols.length && (cols[nfColNo].getFixed() || !cols[nfColNo].getVisible()))
			{
				if(nfColNo<cols.length && cols[nfColNo].getVisible() && cols[nfColNo].hasCells())
					realColNo++;
				nfColNo++;
			}
			if(nfColNo==cols.length)
				continue;
			igtbl_lineupHeaders(cols[nfColNo].Id,this.Bands[i]);
			if(i==0 && isInit)
			{
				divs.firstChild.style.width=this.Element.offsetWidth + (this.GroupCount==1?this.Indentation:0);
				divs.firstChild.style.height=this.Element.offsetHeight;
			}
			var mColNo=nfColNo,cw=scrollLeft;
			while(mColNo<cols.length)
			{
				var col=cols[mColNo];
				if(col.getVisible() && col.hasCells())
				{
					var w=col.getWidth();
					var c=igtbl_getDocumentElement(col.Id),c1=null;
					if(col.Band.ColFootersVisible==1 && (this.StationaryMargins==2 || this.StationaryMargins==3))
						c1=igtbl_getDocumentElement(col.fId);
					if(w<=cw)
						igtbl_setColVisible([c,c1],realColNo==fac?"":"none",realColNo==fac?1:0,realColNo);
					else if(cw>0 && w>cw)
					{
						if(this.FixedColumnScrollType!=1 && ig_csom.IsIE)
							igtbl_setColVisible([c,c1],"",w-cw,realColNo);
						else
						{
							if(cw>w/2||((parseInt(divf.scrollWidth,10)-parseInt(divf.offsetWidth,10))<w))
								igtbl_setColVisible([c,c1],realColNo==fac?"":"none",realColNo==fac?1:0,realColNo);
							else
								igtbl_setColVisible([c,c1],"",w,realColNo);
						}
					}
					else
						igtbl_setColVisible([c,c1],"",w,realColNo);
					if(cw>0)
					{
						cw-=w;
						if(cw<0) cw=0;
					}
					realColNo++;
				}
				mColNo++;
			}
		}
	}
},
"_recalcRowNumbers",
function(row)
{
	if(this.AllowRowNumbering<2 || this.ClientSideRenumbering!=1) return;
	
	for(var i=0; i<this.Bands.length;i++)
		this.Bands[i]._currentRowNumber=0;
	
	if (!row) 
		igtbl_RecalculateRowNumbers(this.Rows,1,this.Bands[0],this.Rows.Node);
	else
		switch(row.Band.AllowRowNumbering)
		{
			case(2):
			case(4):
				igtbl_RecalculateRowNumbers(this.Rows,1,this.Bands[0],this.Rows.Node);
				break;
			case(3):
				var rc = row.ParentRow?row.ParentRow.Rows:this.Rows;					
				igtbl_RecalculateRowNumbers(rc,1,rc.Band,rc.Node);
				break;
		}
},
"_calculateStationaryHeader",
function()
{

	if (this.StatHeader&&(this.StationaryMargins==1 || this.StationaryMargins==3))
	{
		if (this.Rows && this.Rows.length>0)
		{
			this.StatHeader.Element.parentNode.parentNode.parentNode.parentNode.style.display="";			
			this.DivElement.firstChild.children[1].style.display="none";			
		}
		else
		{
			this.StatHeader.Element.parentNode.parentNode.parentNode.parentNode.style.display="none";			
			this.DivElement.firstChild.children[1].style.display="";			
		}		
	}
},
"invokeXmlHttpRequest",
function(type,object,data)
{
	var g=this;
	if(!g.Node || g.LoadOnDemand!=3) return;
	switch(type)
	{
		case g.eReqType.UpdateCell:
		{
			var cell=object;
			if(g.LoadOnDemand==3 && (typeof(g.Events.AfterRowUpdate)=="undefined" || g.Events.AfterRowUpdate[1]==0 && (g.Events.XmlHTTPResponse[1]==1 || g.Events.AfterCellUpdate[1]==1)))
			{
				g.QueryString="UpdateCell\x01"+cell.Band.Index+"\x02"+cell.Column.Index+"\x02"+cell.Row.getIndex()+"\x02"+cell.Row.DataKey+"\x02"+data+"\x02"+cell.getLevel(true);
				g.xmlHttpRequest(type);
			}
			break;
		}
		case g.eReqType.AddNewRow:
		{
			var rows=object;
			if((typeof(g.Events.AfterRowUpdate)=="undefined" || g.Events.AfterRowUpdate[1]==0 && g.Events.XmlHTTPResponse[1]==1))
			{
				g.QueryString="AddNewRow\x01"+rows.Band.Index+":"+(rows.ParentRow?rows.ParentRow.getIndex()+":"+rows.ParentRow.DataKey:":");
				g.xmlHttpRequest(type);
			}
			break;
		}
		case g.eReqType.Sort:
		{
			var rows=object;
			rows.sortXml();
			break;
		}
		case g.eReqType.ChildRows:
		{
			var row=object;
			row.requestChildRows();
			break;
		}
		case g.eReqType.DeleteRow:
		{
			if(g.LoadOnDemand==3 && (!g.Events.XmlHTTPResponse || g.Events.XmlHTTPResponse[1] || g.Events.AfterRowDeleted[1]))
			{
				var row = object;
				var cellInfo = row._generateUpdateRowSemaphore();
				g.QueryString="DeleteRow\x01"+row.Band.Index+":"+row.getIndex()+":"+row.DataKey+":"+row.getLevel(true)+":"+row.DataKey+":"+g.RowsRetrieved+"\x04"+(cellInfo.length>0?"CellValues\x02"+cellInfo+"\x04":"");
				g.RowToQuery=row;
				g.xmlHttpRequest(type);
			}
			break;
		}
		case g.eReqType.UpdateRow:
		{
			var row=object;
			var cellInfo="";
			if(row._dataChanged&1)
				g.QueryString="AddNewRow\x02"+(row.ParentRow?row.ParentRow.getLevel(true)+":"+row.ParentRow.DataKey:":")+(g.QueryString.length>0?"\x04":"")+g.QueryString;
			else
				cellInfo=row._generateUpdateRowSemaphore();
			g.QueryString="UpdateRow\x01"+row._dataChanged+":"+row.Band.Index+":"+row.getLevel(true)+":"+row.DataKey+":"+g.RowsRetrieved+"\x04"+(cellInfo.length>0?"CellValues\x02"+cellInfo+"\x04":"")+g.QueryString;
			g.RowToQuery=row;
			g.xmlHttpRequest(type);
			break;
		}
		case g.eReqType.MoreRows:
		{
			var de=g.DivElement;
			de.setAttribute("oldST",de.scrollTop.toString());
			if(g.RowsServerLength>g.Rows.length)
			{
				g.QueryString="NeedMoreRows\x01"+g.RowsRetrieved+"\x02"+g.Rows.length.toString();
				var sortOrder="";
				for(var i=0;i<g.Bands[0].SortedColumns.length;i++)
				{
					var col=igtbl_getColumnById(g.Bands[0].SortedColumns[i]);
					sortOrder+=col.Key+(col.SortIndicator==2?" DESC":"")+(i<g.Bands[0].SortedColumns.length-1?",":"");
				}
				if(sortOrder)
					g.QueryString+="\x02"+sortOrder;
				g.xmlHttpRequest(g.eReqType.MoreRows);
				de.setAttribute("noOnScroll","true");
				window.setTimeout("igtbl_cancelNoOnScroll('"+g.Id+"')",100);
			}
			break;
		}
		case g.eReqType.Custom:
		{
			g.QueryString="Custom\x01"+data;
			g.xmlHttpRequest(g.eReqType.Custom);
			break;
		}
	}
}
];
for(var i=0;i<igtbl_ptsGrid.length;i+=2)
	igtbl_Grid.prototype[igtbl_ptsGrid[i]]=igtbl_ptsGrid[i+1];

var igtbl_waitDiv=null;
var igtbl_wndOldCursor="";

/* Band object */
igtbl_Band.prototype=new igtbl_WebObject();
igtbl_Band.prototype.constructor=igtbl_Band;
igtbl_Band.base=igtbl_WebObject.prototype;
function igtbl_Band(grid,node,index)
{
	if(arguments.length>0)
		this.init(grid,node,index);
}
var igtbl_ptsBand=[
"init",
function(grid,node,index)
{
	igtbl_Band.base.init.apply(this,["band",null,node]);

	this.Grid=grid;
	this.Index=index;
	var defaultProps=new Array("Key","AllowAddNew","AllowColSizing","AllowDelete","AllowSort","ItemClass","AltClass","AllowUpdate",
								"CellClickAction","ColHeadersVisible","ColFootersVisible","CollapseImage","CurrentRowImage",
								"CurrentEditRowImage","DefaultRowHeight","EditCellClass","Expandable","ExpandImage",
								"FooterClass","GroupByRowClass","GroupCount","HeaderClass","HeaderClickAction","Visible",
								"IsGrouped","ExpAreaClass","NonSelHeaderClass","RowLabelClass","SelGroupByRowClass","SelHeadClass",
								"SelCellClass","RowSizing","SelectTypeCell","SelectTypeColumn","SelectTypeRow","RowSelectors",
								"NullText","RowTemplate","ExpandEffects","AllowColumnMoving","ClientSortEnabled","Indentation",
								"RowLabelWidth","DataKeyField","FixedHeaderIndicator","AllowRowNumbering");
	this.VisibleColumnsCount=0;
	this.Columns = new Array();
	var bandArray;
	try{bandArray=eval("igtbl_"+grid.Id+"_Bands["+index.toString()+"]");}catch(e){}
	var bandCount=0;
	if(bandArray)
	{
		bandCount=eval("igtbl_"+grid.Id+"_Bands").length;
		for(var i=0;i<bandArray.length;i++)
			this[defaultProps[i]]=bandArray[i];
		if(this.RowTemplate!="")
			this.ExpandEffects=new igtbl_expandEffects(this.ExpandEffects);
	}	
	else
		bandCount=this.Node.parentNode.selectNodes("Band").length;	
	var colsArray=eval("igtbl_"+grid.Id+"_Columns_"+index.toString());
	if(!node)
	{
		for(var i=0;i<colsArray.length;i++)
		{
			this.Columns[i]=new igtbl_Column(null,this,i);
			if(!this.Columns[i].Hidden)
				this.VisibleColumnsCount++;
		}
	}
	else
	{
		this.Columns.Node=this.Node.selectSingleNode("Columns");
		var columNodes=this.Columns.Node.selectNodes("Column");
		var nodeIndex=0;
		for(var i=0;i<columNodes.length;i++)
		{
			this.Columns[i]=new igtbl_Column(columNodes[i],this,i,nodeIndex);
			if(!this.Columns[i].Hidden && this.Columns[i].hasCells())
				this.VisibleColumnsCount++;
			if(!colsArray[i][33])
				nodeIndex++;
		}
	}
	igtbl_dispose(defaultProps);

	if(grid.AddNewBoxVisible)
	{
		if(this.Index==0)
			this.curTable=grid.Element;
		var addNew=igtbl_getElementById(grid.Id+"_addBox");
		if(grid.AddNewBoxView==0)
			this.addNewElem = addNew.childNodes[0].rows[0].cells[1].childNodes[0].rows[this.Index].cells[this.Index];
		else
			this.addNewElem = addNew.childNodes[0].rows[0].cells[1].childNodes[0].rows[0].cells[this.Index*2];
	}
	this.SortedColumns=new Array();

	var rs=this.getRowSelectors();
	if(bandCount==1)
	{
		if(rs==2)
			this.firstActiveCell=0;
		else
			this.firstActiveCell=1;
	}
	else
	{
		if(rs==2)
			this.firstActiveCell=1;
		else
			this.firstActiveCell=2;
	}
},
"getSelectTypeRow",
function()
{
	var res=this.Grid.SelectTypeRow;
	if(this.SelectTypeRow!=0)
		res=this.SelectTypeRow;
	return res;
},
"getSelectTypeCell",
function()
{
	var res=this.Grid.SelectTypeCell;
	if(this.SelectTypeCell!=0)
		res=this.SelectTypeCell;
	return res;
},
"getSelectTypeColumn",
function()
{
	var res=this.Grid.SelectTypeColumn;
	if(this.SelectTypeColumn!=0)
		res=this.SelectTypeColumn;
	return res;
},
"getColumnFromKey",
function(key)
{
	var column=null;
	for(var i=0;i<this.Columns.length;i++)
		if(this.Columns[i].Key==key)
		{
			column=this.Columns[i];
			break;
		}
	return column;
},
"getExpandImage",
function()
{
	var ei=this.Grid.ExpandImage;
	if(this.ExpandImage!="")
		ei=this.ExpandImage;
	return ei;
},
"getCollapseImage",
function()
{
	var ci=this.Grid.CollapseImage;
	if(this.CollapseImage!="")
		ci=this.CollapseImage;
	return ci;
},
"getRowStyleClassName",
function()
{
	if(this.ItemClass!="")
		return this.ItemClass;
	return this.Grid.ItemClass;
},
"getRowAltClassName",
function()
{
	if(this.AltClass!="")
		return this.AltClass;
	return this.Grid.AltClass;
},
"getExpandable",
function()
{
	if(this.Expandable!=0)
		return this.Expandable;
	else return this.Grid.Expandable;
},
"getCellClickAction",
function()
{
	var res=this.Grid.CellClickAction;
	if(this.CellClickAction!=0)
		res=this.CellClickAction;
	return res;
},
"getExpAreaClass",
function()
{
	if(this.ExpAreaClass!="")
		return this.ExpAreaClass;
	return this.Grid.ExpAreaClass;
},
"getRowLabelClass",
function()
{
	if(this.RowLabelClass!="")
		return this.RowLabelClass;
	return this.Grid.RowLabelClass;
},
"getItemClass",
function()
{
	if(this.ItemClass!="")
		return this.ItemClass;
	return this.Grid.ItemClass;
},
"getAltClass",
function()
{
	if(this.AltClass!="")
		return this.AltClass;
	else if(this.Grid.AltClass!="")
		return this.Grid.AltClass;
	else if(this.ItemClass!="")
		return this.ItemClass;
	return this.Grid.ItemClass;
},
"getSelClass",
function()
{
	if(this.SelCellClass!="")
		return this.SelCellClass;
	return this.Grid.SelCellClass;
},
"getFooterClass",
function()
{
	if(this.FooterClass!="")
		return this.FooterClass;
	return this.Grid.FooterClass;
},
"getGroupByRowClass",
function()
{
	if(this.GroupByRowClass!="")
		return this.GroupByRowClass;
	return this.Grid.GroupByRowClass;
},
"addNew",

⌨️ 快捷键说明

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