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

📄 datagrid.htm

📁 网上商城的设计与实现
💻 HTM
📖 第 1 页 / 共 2 页
字号:
		strDetail += '>';

		// determine format per data column
		if (typeof(this.colFormat[nCol]) != 'undefined')
		{ // use column format
			strDetail += this.colFormat[nCol];
		}
		else if (this.rowFormat.length)
		{ // use row format
			var nRow = this._rowCount % this.rowFormat.length;
			strDetail += this.rowFormat[nRow];
		}

		strDetail += eval(this.colData[nCol]);
		strDetail += '</TD>\n';
	}

	return strDetail;
}

function _DG__display()
{	
	var objRS = this._objDataSource;

	var strHeader = '<TABLE ' + this.tableAttributes + '>\n';
	var nHeaderCols = this.colHeader.length;
	if (nHeaderCols)
	{
		strHeader += '<TR ' + this.headerAttributes + '>\n';
		for (var nCol=0; nCol < nHeaderCols; nCol++)
			strHeader += '<TH ' + this.headerWidth[nCol] + '>' + this.headerFormat + eval(this.colHeader[nCol]) + '</TH>\n';
					
		strHeader += '</TR>\n';
	}
	
	var strBody = '';
	var nRowToScroll = 0;
	
	for (this._rowCount = 0; this._rowCount < this._rowInfo.length; ++this._rowCount)
	{
		var nPos = (this._curPage) * this.pageSize + this._rowCount + 1;
		if (this.rowAttributes.length)
		{	// apply row attributes to <TR>
			var nRow = this._rowCount % this.rowAttributes.length;
			strBody += '<TR ' + this.rowAttributes[nRow] + '>\n';
		}
		else
			strBody += '<TR>\n';
			
		if (this.hiliteAttributes.length && nPos == this._objDataSource.absolutePosition)
		{
			nRowToScroll =  this._rowCount;
			strBody +=  this._evalSingleRow(this.hiliteAttributes);
		}
		else
			strBody += this._rowInfo[this._rowCount];
			
		strBody += '</TR>';
	}
	
	this._rowCount = 0;
	var objInnerTable = this.rows(0).cells(0);
	objInnerTable.innerHTML = strHeader + strBody + '</TABLE>';	
	//fix scrollIntoView and hilite for TDs
	if (objInnerTable.children(0).rows(nRowToScroll) != null)
		objInnerTable.children(0).rows(nRowToScroll).scrollIntoView(true);
} 

function _DG__syncTableProperties()
{
	var objInnerTable = this.rows(0).cells(0).children(0);
	this.align = objInnerTable.align;
	this.width = objInnerTable.width;
	objInnerTable.width = "100%";
	this.bgcolor = objInnerTable.bgcolor;
}

function _DG__onclick()
{
	var objDataGrid = event.srcElement;
	var bFound = false;
	var nIndexAux = 0;
	var nIndex = 0;
	
	if (document.selection.type != 'None')
		return;

	while ((!bFound) && (typeof(objDataGrid) != 'undefined') && (objDataGrid != null))
	{
		if (typeof(objDataGrid.navbar) == 'string')
			return;
			
		if (objDataGrid.tagName == 'TR')
		{
			nIndex = nIndexAux;
			nIndexAux = objDataGrid.rowIndex;
		}
		
		if ((typeof(objDataGrid._auxID) == 'string') && (objDataGrid._auxID == 'DataGrid'))
			bFound = true;
		else
			objDataGrid	= objDataGrid.parentElement;
	}
		
	if ((bFound) && (typeof(objDataGrid.hiliteAttributes) != 'undefined') && (objDataGrid.hiliteAttributes != null) && (objDataGrid.hiliteAttributes.length))
	{
		var objRS = objDataGrid._objDataSource;

		if ((typeof(objRS) != 'undefined') && (objRS != null))
		{
			var nPos = objRS.absolutePosition;
			var nOffset = objDataGrid.pageSize * objDataGrid._curPage;
				
			if ((this.colHeader.length == 0) || !this.displayHeader) ++nIndex;
			
			if (nIndex != 0)
				objRS.moveAbsolute(nOffset + nIndex);
					
			objDataGrid.focus();
		}		
	}
 }
 
function _DG__onkeydown()
{
	var objDataGrid = event.srcElement;
	var bFound = false;
	
	while ((!bFound) && (typeof(objDataGrid) != 'undefined') && (objDataGrid != null))
	{
		if ((typeof(objDataGrid._auxID) == 'string') && (objDataGrid._auxID == 'DataGrid'))
			bFound = true;
		else
			objDataGrid	= objDataGrid.parentElement;
	}
	
	if ((bFound) && (typeof(objDataGrid.hiliteAttributes) != 'undefined') && (objDataGrid.hiliteAttributes != null) && (objDataGrid.hiliteAttributes.length))
	{
		var objRS = objDataGrid._objDataSource;		
		if (objRS != null)
		{
			var nKey = window.event.keyCode;
			if (nKey == 40) //down arrow
			{
				if (!objRS.EOF)
					objRS.moveNext();
			}
			else if (nKey == 38) //up arrow
			{
				if (!objRS.BOF)
					objRS.movePrevious();
			}
			else if (nKey == 34)
			{
				var nPos = objRS.absolutePosition + objDataGrid.pageSize;
				if (nPos > objRS.getCount())
					objRS.moveLast();
				else
					objRS.moveAbsolute(nPos);
					
			}
			else if (nKey == 33)
			{
				var nPos = objRS.absolutePosition - objDataGrid.pageSize;
				if (nPos < 1)
					objRS.moveFirst();
				else
					objRS.moveAbsolute(nPos);
					
			}
			else if (nKey == 36)
				objRS.moveFirst();
			else if (nKey == 35)
				objRS.moveLast();
			else
				return;
				
		}
	}	
}

function _DG__onrowenter(objDataGrid)
{
	if (! objDataGrid._bExclusive)
	{
		if (objDataGrid._bEvalingInfo)
			objDataGrid._rowInfo[objDataGrid._rowInfo.length] = objDataGrid._evalSingleRow();	
		else
		{
			var objRS = objDataGrid._objDataSource;
			var nPos = objRS.absolutePosition;
			if (nPos <= 0)
			{
				if ((nPos == 0) || (nPos == -1)) //Start, unknown or empty recordset
					objDataGrid._rowInfo.length = 0;
				else 	
					return;
			}
			else
			{
				var curPage;		
				if (objDataGrid.pageSize > 0)
					curPage = ((nPos -1) - ((nPos - 1) % objDataGrid.pageSize)) / objDataGrid.pageSize;
				else
					curPage = 0;
					
				if (curPage != objDataGrid._curPage)	
				{	
					if (typeof(objRS._rsRDS.InternetTimeout) == 'undefined')
					{	// RDS 1.5 does not allow cursor movement in onrowenter handler
						if (window.event != null && window.event.type == 'rowenter')
						{	// defer movement until after exiting onrowenter handler
							window.setTimeout('_DG__onrowenter(' + objDataGrid.id + ')',0);
							return;
						}
					}

					objDataGrid._bExclusive = true;
					objRS.moveAbsolute((curPage * objDataGrid.pageSize) + 1);
					objDataGrid._bExclusive = false;
					
					objDataGrid._curPage = curPage;
					objDataGrid._evalRowInfo();
					
					objDataGrid._bExclusive = true;
					objRS.moveAbsolute(nPos);
					objDataGrid._bExclusive = false;
				}	
			}	
			objDataGrid._display();
			objDataGrid._syncTableProperties();
		}
	}
}

function _DG__onafterupdate(objDataGrid, bDisplay)
{
	var objRS = objDataGrid._objDataSource;
	var	nPos = objRS.absolutePosition;

	if ((objDataGrid.pageSize == 0) || ((nPos > objDataGrid._curPage * objDataGrid.pageSize) && 
		(nPos <= (objDataGrid._curPage + 1) * objDataGrid.pageSize)))
	{
		objDataGrid._evalRowInfo();
			
		objDataGrid._bExclusive = true;
		objRS.moveAbsolute(nPos);
		objDataGrid._bExclusive = false;
	}
	else if (nPos == 0)
		objDataGrid._rowInfo.length = 0;

	if (typeof(bDisplay) == 'boolean' && bDisplay == true)
	{
		objDataGrid._display();
		objDataGrid._syncTableProperties();
	}
}

function _DG__bodyonafterupdate()
{	
	var objRS = _DG__findRecordSource(event.srcElement);
	
	if ((objRS != null) && (typeof(objRS._objEventManager) != 'undefined'))
		objRS._objEventManager.fireEvent(DG_ONAFTERUPDATE);
}

function _DG__findRecordSource(objSrcElement)
{
	var bFound = false;
	var objSrc = objSrcElement;
	
	while ((!bFound) && (typeof(objSrc) != 'undefined') && (objSrc != null))
	{
		if (typeof(objSrc.getDataSource) != 'undefined')
			bFound = true;
		else
			objSrc = objSrc.parentElement;
	}	
	
	if (bFound)
		return objSrc.getDataSource();
	else
		return null;
}

⌨️ 快捷键说明

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