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

📄 zpgrid-output.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 5 页
字号:
	if (bFixed) {		aTr.push('Fixed');	}	aTr.push('" class="');	aTr.push(sClass);	if (this.config.activeRows) {		aTr.push('" onmouseover="if(!Zapatec.Grid.mouseSelection)if(this.className.indexOf(\'zpGridRowActive\')==-1){this.className+=\'');		aTr.push(sClassActive);		aTr.push("'");		if (bFixed) {			aTr.push(";document.getElementById('zpGrid");			aTr.push(this.id);			aTr.push('Row');			aTr.push(oRow.i);			aTr.push("').className+='");			aTr.push(sClassActive);			aTr.push("'");		} else if (this.config.fixedLeft > 0 && !this.config.visibleColumns) {			aTr.push(";document.getElementById('zpGrid");			aTr.push(this.id);			aTr.push('Row');			aTr.push(oRow.i);			aTr.push("Fixed').className+='");			aTr.push(sClassActive);			aTr.push("'");		}		aTr.push("}\" onmouseout=\"if(!Zapatec.Grid.mouseSelection)this.className=this.className.replace(/ zpGridRowActive[^ ]*/g,'')");		if (bFixed) {			aTr.push(";var oRow=document.getElementById('zpGrid");			aTr.push(this.id);			aTr.push('Row');			aTr.push(oRow.i);			aTr.push("');oRow.className=oRow.className.replace(/ zpGridRowActive[^ ]*/g,'')");		} else if (this.config.fixedLeft > 0 && !this.config.visibleColumns) {			aTr.push(";var oRow=document.getElementById('zpGrid");			aTr.push(this.id);			aTr.push('Row');			aTr.push(oRow.i);			aTr.push("Fixed');oRow.className=oRow.className.replace(/ zpGridRowActive[^ ]*/g,'')");		}	}	aTr.push('" ondblclick="this.onmouseout()" style="');	if (oRow.style) {		aTr.push(oRow.style);	}	aTr.push('">');	// Display cells	if (bFixed) {		for (var iCol = 0; iCol < iFixedCols; iCol++) {			this.outputCell(aTr, aFixedCols[iCol], oRow, iRow, iCol, iCols);		}	} else {		for (var iCol = 0; iCol < iCols; iCol++) {			var bHidden = (iCol < iFixedCols);			this.outputCell(aTr, aCols[iCol], oRow, iRow, iCol, iCols, bHidden);		}	}	aTr.push('</tr>');	aHtml.push(aTr.join(''));};/** * Forms grid output. * * @private * @param {object} aTr Output array * @param {object} oField Field object * @param {object} oRow Row object * @param {object} iRow Number of row on the page * @param {number} iCol Visible column number * @param {number} iCols Visible column count * @param {boolean} bHidden Optional. Indicates that this is hidden part of * fixed part of row */Zapatec.Grid.prototype.outputCell = function(aTr, oField, oRow, iRow, iCol, iCols, bHidden) {	if (oField.i >= this.config.fixedLeft &&	 oField.i < this.currentHorizontalOffset + this.config.fixedLeft) {		// Hidden column		return;	}	if (this.config.visibleColumns) {		bHidden = false;	}	// Get cell	var iField = oField.i;	var oCell = this.getCellByRow(oRow, iField);	if (!oCell) {		return;	}	var oConfig = this.config;	var iGrid = this.id;	var iRow = oRow.i;	var iCell = oCell.i;	var sId = ['zpGrid', iGrid, 'Row', iRow, 'Cell', iCell].join('');	var aCl = [];	aCl.push('zpGridCell zpGridCell');	aCl.push(iCol);	aCl.push(' zpGridColId');	aCl.push(iField);	aCl.push(' zpGridCellData zpGridCellData');	aCl.push(iCol);	if (iCol % 2 == 1) {		aCl.push(' zpGridCellOdd zpGridCellDataOdd');	} else {		aCl.push(' zpGridCellEven zpGridCellDataEven');	}	if (iCol + 1 == iCols) {		aCl.push(' zpGridCellLast zpGridCellDataLast');	}	if (oConfig.selectCells && oCell.selected) {		aCl.push(' zpGridCellSelected zpGridCellSelected');		aCl.push(iCol);		if (iCol % 2 == 1) {			aCl.push(' zpGridCellSelectedOdd');		} else {			aCl.push(' zpGridCellSelectedEven');		}		if (iCol == iCols - 1) {			aCl.push(' zpGridCellSelectedLast');		}	}	if (oCell.invalid) {		aCl.push(' zpGridCellInvalid zpGridCellInvalid');		aCl.push(iCol);		if (iCol % 2 == 1) {			aCl.push(' zpGridCellInvalidOdd');		} else {			aCl.push(' zpGridCellInvalidEven');		}		if (iCol == iCols - 1) {			aCl.push(' zpGridCellInvalidLast');		}	}	var sClass = aCl.join('');	var aClA = [];	aClA.push(' zpGridCellActive zpGridCellActive');	aClA.push(iCol);	aClA.push(' zpGridCellDataActive zpGridCellDataActive');	aClA.push(iCol);	if (iCol % 2 == 1) {		aClA.push(' zpGridCellActiveOdd zpGridCellDataActiveOdd');	} else {		aClA.push(' zpGridCellActiveEven zpGridCellDataActiveEven');	}	if (iCol == iCols - 1) {		aClA.push(' zpGridCellActiveLast zpGridCellDataActiveLast');	}	var sClassActive = aClA.join('');	var aTd = [];	aTd.push('<td class="');	aTd.push(sClass);	aTd.push('" id="');	aTd.push(sId);	if (bHidden) {		aTd.push('Hidden');	} else {		if (oConfig.activeCells) {			aTd.push('" onmouseover="if(Zapatec.Grid.mouseSelection)Zapatec.Grid.mouseOverCell=this.id;else if(this.className.indexOf(\'zpGridCellActive\')==-1)this.className+=\'');			aTd.push(sClassActive);			aTd.push('\'" onmouseout="if(!Zapatec.Grid.mouseSelection)this.className=this.className.replace(/ zpGrid[^ ]+Active[^ ]*/g,\'\')');		}		aTd.push('" onclick="Zapatec.Grid.rowOnClick(\'');		aTd.push(iGrid);		aTd.push("','");		aTd.push(iRow);		aTd.push("','");		aTd.push(iCell);		aTd.push('\')" ondblclick="this.onmouseout();Zapatec.Grid.rowOnDblClick(\'');		aTd.push(iGrid);		aTd.push("','");		aTd.push(iRow);		aTd.push("','");		aTd.push(iCell);		aTd.push("')");		aTd.push('" onmousedown="Zapatec.Widget.callMethod(');		aTd.push(iGrid);		aTd.push(",'fireEvent','gridCellMousedown',");		aTd.push(iRow);		aTd.push(',');		aTd.push(iCell);		aTd.push(')');		aTd.push('" onmouseup="Zapatec.Widget.callMethod(');		aTd.push(iGrid);		aTd.push(",'fireEvent','gridCellMouseup',");		aTd.push(iRow);		aTd.push(',');		aTd.push(iCell);		aTd.push(')');	}	var sStyle = this.getCellStyle(oCell, iRow);	if (sStyle) {		aTd.push('" style="');		aTd.push(sStyle);	}	var iColspan = oCell.colspan;	if (iColspan > 1) {		aTd.push('" colspan="');		aTd.push(iColspan);	}	var iRowspan = oCell.rowspan;	if (iRowspan > 1) {		aTd.push('" rowspan="');		aTd.push(iRowspan);	}	aTd.push('">');	this.outputCellValue(aTd, oField, oCell);	aTd.push('</td>');	aTr.push(aTd.join(''));};/** * Forms grid output. * * @private * @param {object} aTd Output array * @param {object} oField Field object * @param {object} oCell Cell object * @param {boolean} bHid Optional. If true, visibility is hidden */Zapatec.Grid.prototype.outputCellValue = function(aTd, oField, oCell, bHid) {	var sId = ['zpGrid', this.id, 'Row', oCell.r, 'Cell', oCell.i].join('');	// div is needed to be able to set column width	aTd.push('<div id="');	aTd.push(sId);	aTd.push('Div" class="zpGridDiv');	// Set cell type	if (this.getClassByType) {		aTd.push(' ');		aTd.push(this.getClassByType(this.getFieldType(oField)));	}	aTd.push('" onselectstart="return false" style="-moz-user-select:none;');	var iRowspan = oCell.rowspan;	if (iRowspan > 1) {		var aMatch = this.config.rowHeight.match(/^(\d+)(\D+)$/);		if (aMatch && aMatch.length == 3) {			aTd.push('height:');			aTd.push(aMatch[1] * iRowspan + iRowspan - 1);			aTd.push(aMatch[2]);			aTd.push(';');		}	}	var iCellspan = oCell.colspan;	if (bHid || iCellspan > 1) {		if (bHid) {			aTd.push('visibility:hidden;');		}		if (iCellspan > 1) {			// Calculate cell width			var iW = 0;			// Cell id			var iCell = oCell.i;			// Fields array			var aF = this.fields;			// Default column width			var sCW = this.config.columnWidth;			var iCW = sCW * 1;			// Variables used in the loop			var iC, oF, sW;			for (iC = 0; iC < iCellspan; iC++) {				oF = aF[iCell + iC];				if (oF && !oF.hidden) {					sW = oF.columnWidth;					if (sW) {						iW += sW * 1;					} else if (sCW) {						iW += iCW;					} else {						iW = 0;						break;					}				}			}			if (iW) {				aTd.push('width:');				aTd.push(iW);				aTd.push('px;');			} else {				aTd.push('width:auto;');			}		}	}	aTd.push('">');	var sData = this.getCellData(oCell);	if (sData && typeof sData != 'string') {		sData = sData.toString();	}	// Empty cell may cause visual problems in editable grid extension	if (!sData || !sData.length) {		sData = '&nbsp;';	}	aTd.push(sData);	aTd.push('</div>');};/** * Forms grid output. * * @private * @param {object} aHtml Output array * @param {number} iContainer Optional. Number of container if there are two and * more pagination containers */Zapatec.Grid.prototype.outputPagination = function(aHtml, iContainer) {	if (typeof this.config.callbackPaginationDisplay == 'function' ||	 this.config.rowsPerPage <= 0) {		// No pagination		return;	}	// We need this only for second and further containers	if (!iContainer || iContainer < 2) {		iContainer = '';	} else {		iContainer = '_' + iContainer;	}	if (this.paginationContainers.length) {		aHtml.push('<div id="zpGrid');		aHtml.push(this.id);		aHtml.push('PaginationContainer');		aHtml.push(iContainer);		aHtml.push('"><div><table class="');		aHtml.push(this.getClassName({prefix: 'zpGrid'}));		aHtml.push('" cellpadding="0" cellspacing="0" \		 style="width:100%"><tbody>');	}	aHtml.push('<tr><td class="zpGridPagination" id="zpGrid');	aHtml.push(this.id);	aHtml.push('Pagination');	aHtml.push(iContainer);	aHtml.push('">');	aHtml.push(this.getMessage('labelPage'));	if (this.currentPage > 0) {		// Don't display previous on the first page		aHtml.push(' <span id="zpGrid');		aHtml.push(this.id);		aHtml.push('FirstPage');		aHtml.push(iContainer);		aHtml.push('" class="zpGridFirstPage" \		 onclick="Zapatec.Grid.firstPage(\'');		aHtml.push(this.id);		aHtml.push('\')">&lt;&lt;</span> <span id="zpGrid');		aHtml.push(this.id);		aHtml.push('PrevPage');		aHtml.push(iContainer);		aHtml.push('" class="zpGridPrevPage" \		 onclick="Zapatec.Grid.previousPage(\'');		aHtml.push(this.id);		aHtml.push('\')">&lt;</span>');	}	// Get number of pages	var iPages = this.totalPages();	// Display up to 10 pages	var iCurrentPage = this.getCurrentPageNumber();	var iFirstPage = iCurrentPage - 4;	var iLastPage = iCurrentPage + 5;	for (var iPage = iFirstPage; iPage < iLastPage && iPage <= iPages; iPage++) {		if (iPage < 1) {			// Current page < 10			continue;		}		aHtml.push(' <span id="zpGrid');		aHtml.push(this.id);		aHtml.push('Page');		aHtml.push(iPage);		aHtml.push(iContainer);		aHtml.push('" class="zpGrid');		if (iPage == iCurrentPage) {			aHtml.push('CurrentPage">');		} else {			aHtml.push('Page" onclick="Zapatec.Grid.gotoPage(\'');			aHtml.push(this.id);			aHtml.push("','");			aHtml.push(iPage);			aHtml.push('\')">');		}		aHtml.push(iPage);		aHtml.push('</span>');	}	if (this.currentPage < iPages - 1) {		// Don't display next on the last page		aHtml.push(' <span id="zpGrid');		aHtml.push(this.id);		aHtml.push('NextPage');		aHtml.push(iContainer);		aHtml.push('" class="zpGridNextPage" \		 onclick="Zapatec.Grid.nextPage(\'');		aHtml.push(this.id);		aHtml.push('\')">&gt;</span> <span id="zpGrid');		aHtml.push(this.id);		aHtml.push('LastPage');		aHtml.push(iContainer);		aHtml.push('" class="zpGridLastPage" \		 onclick="Zapatec.Grid.lastPage(\'');		aHtml.push(this.id);		aHtml.push('\')">&gt;&gt;</span>');	}	aHtml.push(' ');	aHtml.push(this.getMessage('labelOf'));	aHtml.push(' ');	aHtml.push(iPages);	aHtml.push(' (');	aHtml.push(this.recordsDisplayed());	aHtml.push(' ');	aHtml.push(this.getMessage('labelRows'));	aHtml.push(')</td></tr>');	if (this.paginationContainers.length) {		aHtml.push('</tbody></table></div></div>');	}};/** * Displays grid. Forms new grid as plain HTML. Pushes strings into array, then * joins array to achieve maximum speed. Replaces previous contents of container * element with formed grid. Adds classes that can be used to create different * themes. Adds user defined styles. * @private */Zapatec.Grid.prototype.refreshContainer = function() {	var oConfig = this.config;	// Check container	var oContainer = this.container;	if (!oContainer) {		alert(this.getMessage('errorContainer'));		return;	}	var oContainerStyle = oContainer.style;	oContainerStyle.position = 'relative';	// IE6 requires width for relative element containing other relative elements	if (oContainer.currentStyle && 	 oContainer.currentStyle['width'] == 'auto') {		oContainerStyle.width = '100%';	}	// Get columns to display, fixed columns and spans	var aCols = [];	var aFixedCols = [];	var aSpans = [];	var aFields = this.fields;	var iFields = aFields.length;	var iFixedFields = Math.min(iFields, oConfig.fixedLeft);	var iField, oField, oSpan;	for (iField = 0; iField < iFields; iField++) {		oField = aFields[iField];		// Skip hidden columns		if (!oField || oField.hidden) {			continue;		}		// Add visible column		aCols.push(oField);		// Add fixed column		if (iField < iFixedFields) {			aFixedCols.push(oField);		}		// Get span		oSpan = this.getFieldSpanned(oField);		if (oSpan) {			aSpans[iField] = oSpan;		}	}	// Get rows to display	var aRows = this.prepareSpans(Zapatec.Utils.clone(this.applyPaging()), true);	// Get totals	var aTotals;	if (this.getTotals) {		aTotals = this.getTotals();

⌨️ 快捷键说明

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