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

📄 zpgrid-output.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 5 页
字号:
	}};/** * Synchronizes containers when theme is loaded. Attached to loadThemeEnd event. * @private */Zapatec.Grid.prototype.visualizeThemeLoad = function() {	if (!this.visualize) {		return;	}	this.syncContainers();};/** * Synchronizes containers when grid is refreshed. * @private */Zapatec.Grid.prototype.visualizeRefresh = function() {	this.syncContainers();};/** * Sets column widths and row heights after data loading. Attached to * loadDataEnd event. * @private */Zapatec.Grid.prototype.visualizeDataLoad = function() {	if (!this.container || !this.visualize) {		return;	}	// We don't need this listener any more	// Because when dataOnDemand is used, loadDataEnd event may occur several	// times and it will overwrite column sizes set manually	this.removeEventListener('loadDataEnd', this.visualizeDataLoad);	// If there is separate container for header	if (this.headerContainer) {		// Set header overflow		this.headerContainer.style.overflow = 'hidden';	}	// If there is separate container for totals	if (this.totalsContainer) {		// Set totals overflow		this.totalsContainer.style.overflow = 'hidden';	}	// Sets column widths and row heights	this.outSetCellDims();};/** * Sets column widths and row heights. * @private */Zapatec.Grid.prototype.outSetCellDims = function() {	// Get stylesheet	if (!Zapatec.StyleSheet) {		return;	}	var oStyle = new Zapatec.StyleSheet(true);	var aTpl = [		'#zpGrid',		this.id.toString(),		'',		'Container .zpGridTable .zpGridDiv'	];	var oConfig = this.config;	var bHoriz = oConfig.horizontal;	var sWidth = 'width:' + oConfig.columnWidth;	var sHeight = 'height:' + oConfig.rowHeight;	// Set default column width and row height	var sRule = aTpl.join('');	oStyle.addRule(sRule, sWidth);	oStyle.addRule(sRule, sHeight);	// Header	if (this.headerContainer) {		aTpl[2] = 'Data';		sRule = aTpl.join('');		oStyle.addRule(sRule, sWidth);		oStyle.addRule(sRule, sHeight);	}	// Totals	if (this.totalsContainer) {		aTpl[2] = 'Totals';		sRule = aTpl.join('');		if (!bHoriz) {			oStyle.addRule(sRule, sWidth);		}		oStyle.addRule(sRule, sHeight);	}	if (!bHoriz) {		// Set fixed column widths		var aFields = this.fields;		var iFields = aFields.length;		var iField, iCol, oField, iColWidth;		for (iField = 0, iCol = 0; iField < iFields; iField++) {			// Get field			oField = aFields[iField];			// Skip hidden columns			if (!oField || oField.hidden) {				continue;			}			iColWidth = oField.columnWidth;			if (iColWidth) {				this.outSetColWidth(oField.i, iColWidth);			}			iCol++;		}	}};/** * Sets column width. * * @private * @param {number} iColId Column id * @param {string} iWidth Column width in px */Zapatec.Grid.prototype.outSetColWidth = function(iColId, iWidth) {	// Check arguments	if (!iWidth) {		return;	}	// Get stylesheet	if (!Zapatec.StyleSheet) {		return;	}	var oStyle = new Zapatec.StyleSheet(true);	// Correct CSS length	var sWidth = 'width:' + Zapatec.Utils.correctCssLength(iWidth);	// Set column width	var aTpl = [		'#zpGrid',		this.id.toString(),		'',		'Container .zpGridTable .zpGridColId',		iColId.toString(),		' .zpGridDiv'	];	// Set width for div and td to make sure they both are resized in FF	// To replicate open editable.html in FF and try to minimize all columns	oStyle.addRule(aTpl.join(''), sWidth);	// Prevent setting width of span	if (!this.fields[iColId].span) {		aTpl[5] = '';		oStyle.addRule(aTpl.join(''), sWidth);	}	// Data	if (this.headerContainer) {		aTpl[2] = 'Data';		aTpl[5] = ' .zpGridDiv';		oStyle.addRule(aTpl.join(''), sWidth);		aTpl[5] = '';		oStyle.addRule(aTpl.join(''), sWidth);	}	// Totals	if (this.totalsContainer) {		aTpl[2] = 'Totals';		aTpl[5] = ' .zpGridDiv';		oStyle.addRule(aTpl.join(''), sWidth);		aTpl[5] = '';		oStyle.addRule(aTpl.join(''), sWidth);	}};/** * Changes width of all columns. Useful for dynamic grid resizing. * * @param {string} iWidth New column width in px */Zapatec.Grid.prototype.changeColumnWidth = function(iWidth) {	// Check arguments	if (!iWidth) {		return;	}	// Get stylesheet	if (!Zapatec.StyleSheet) {		return;	}	var oStyle = new Zapatec.StyleSheet(true);	// Correct CSS length	var aTpl = [		'#zpGrid',		this.id.toString(),		'',		'Container .zpGridTable .zpGridCell',		' .zpGridDiv'	];	var sWidth = 'width:' + Zapatec.Utils.correctCssLength(iWidth);	// Set width for div and td to make sure they both are resized in FF	oStyle.addRule(aTpl.join(''), sWidth);	aTpl[4] = '';	oStyle.addRule(aTpl.join(''), sWidth);	// Data	if (this.headerContainer) {		aTpl[2] = 'Data';		aTpl[4] = ' .zpGridDiv';		oStyle.addRule(aTpl.join(''), sWidth);		aTpl[4] = '';		oStyle.addRule(aTpl.join(''), sWidth);	}	// Totals	if (this.totalsContainer) {		aTpl[2] = 'Totals';		aTpl[4] = ' .zpGridDiv';		oStyle.addRule(aTpl.join(''), sWidth);		aTpl[4] = '';		oStyle.addRule(aTpl.join(''), sWidth);	}};/** * Forms grid output. * * @private * @param {object} aHtml Output array * @param {boolean} bFixed (Optional) Indicates that this is fixed part of data * @param {string} aHtml (Otional) Table id */Zapatec.Grid.prototype.outputTableOpen = function(aHtml, bFixed, sId) {	aHtml.push('<table class="');	aHtml.push(this.getClassName({prefix: 'zpGrid'}));	// Prevent text selection	aHtml.push('" cellpadding="0" cellspacing="0" ondrag="return false" style="-khtml-user-select:none"><tbody><tr><td class="zpGridTable');	if (bFixed) {		aHtml.push(' zpGridTableFixed');	}	if (sId) {		aHtml.push('" id="');		aHtml.push(sId);	}	aHtml.push('"><table class="zpGridTableTable');	if (sId) {		aHtml.push('" id="');		aHtml.push(sId);		aHtml.push('Table');	}	aHtml.push('" style="');	if (this.data.style) {		aHtml.push(this.data.style);	}	aHtml.push('"><tbody>');};/** * Forms grid output. * * @private * @param {object} aHtml Output array */Zapatec.Grid.prototype.outputTableClose = function(aHtml) {	aHtml.push('</tbody></table></td></tr></tbody></table>');};/** * Forms grid output. * * @private * @param {object} aHtml Output array * @param {object} aCols Array with field objects to output * @param {object} aFixedCols Array with fixed field objects to output * @param {object} aSpans Array with spans * @param {object} aRows Array with row objects to output * @param {object} aTotals Array with total row objects to output * @param {boolean} bFixed Optional. Indicates that this is fixed part of header */Zapatec.Grid.prototype.outputFields = function(aHtml, aCols, aFixedCols, aSpans, aRows, aTotals, bFixed) {	if (this.config.horizontal) {		// Horizontal layout		this.outputFieldsHoriz(aHtml, aCols, aFixedCols, aSpans, aRows, aTotals,		 bFixed);	} else {		// Vertical layout		this.outputFieldsVert(aHtml, aCols, aSpans, aRows, bFixed);	}};/** * Forms grid output. * * @private * @param {object} aHtml Output array * @param {object} aCols Array with field objects to output * @param {object} aFixedCols Array with fixed field objects to output * @param {object} aSpans Array with spans * @param {object} aRows Array with row objects to output * @param {object} aTotals Array with total row objects to output * @param {boolean} bFixed Optional. Indicates that this is fixed part of header * @param {boolean} bSecondRow (Optional) Indicates that this is second row * of header */Zapatec.Grid.prototype.outputFieldsHoriz = function(aHtml, aCols, aFixedCols, aSpans, aRows, aTotals, bFixed, bSecondRow) {	var iSpanned = 0;	// Fixed columns become header	var iCols = aCols.length;	var iFixedCols = aFixedCols.length;	var iSpans = aSpans.length;	var iRows = aRows.length;	var iTotals = 0;	if (aTotals && !this.totalsContainer && this.outputTotalsCell) {		iTotals = aTotals.length;	}	var iCol, oField, aCl, sClass, aTr, oSpan, iRow;	for (iCol = 0; iCol < iFixedCols; iCol++) {		// Get field object		oField = aFixedCols[iCol];		// Form tr		aCl = [];		aCl.push('zpGridCol zpGridCol');		aCl.push(iCol);		aCl.push(' zpGridColFixed zpGridColFixed');		aCl.push(iCol);		if (iCol % 2 == 1) {			aCl.push(' zpGridColOdd zpGridColFixedOdd');		} else {			aCl.push(' zpGridColEven zpGridColFixedEven');		}		if (iCol == iFixedCols - 1) {			aCl.push(' zpGridColFixedLast');		}		sClass = aCl.join('');		aTr = [];		aTr.push('<tr id="zpGrid');		aTr.push(this.id);		aTr.push('Col');		aTr.push(oField.i);		if (bFixed) {			aTr.push('Fixed');		}		aTr.push('" class="');		aTr.push(sClass);		if (this.data.headerStyle) {			aTr.push('" style="');			aTr.push(this.data.headerStyle);		}		aTr.push('">');		if (iSpans) {			// Output span			oSpan = aSpans[oField.i];			if (oSpan) {				this.outputSpan(aTr, oField, iCol, oSpan, iCols, !bFixed);				iSpanned = oSpan.spanned - 1;				// Output field				this.outputField(aTr, oField, iCol, iCols, !bFixed);			} else {				// Output field				if (iSpanned) {					this.outputField(aTr, oField, iCol, iCols, !bFixed);					iSpanned--;				} else {					this.outputField(aTr, oField, iCol, iCols, !bFixed, true);				}			}		} else {			// Output field			this.outputField(aTr, oField, iCol, iCols, !bFixed);		}		if (!bFixed) {			// Output rows			for (iRow = 0; iRow < iRows; iRow++) {				this.outputCell(aTr, oField, aRows[iRow], iCol, iRow, iRows);			}			// Output totals			for (iRow = 0; iRow < iTotals; iRow++) {				this.outputTotalsCell(aTr, oField, aTotals[iRow], iCol, iRow, iTotals);			}		}		aTr.push('</tr>');		aHtml.push(aTr.join(''));	}};/** * Forms grid output. * * @private * @param {object} aHtml Output array * @param {object} aCols Array with field objects to output * @param {object} aSpans Array with spans * @param {object} aRows Array with row objects to output * @param {boolean} bFixed Optional. Indicates that this is fixed part of header * @param {boolean} bSecondRow Optional. Indicates that this is second row of * header */Zapatec.Grid.prototype.outputFieldsVert = function(aHtml, aCols, aSpans, aRows, bFixed, bSecondRow) {	var aTr = [];	aTr.push('<tr id="zpGrid');	aTr.push(this.id);	aTr.push('Head');	if (bFixed) {		aTr.push('Fixed');	}	if (bSecondRow) {		aTr.push('2');	}	aTr.push('" class="zpGridRow zpGridHeadRow zpGridRow0 zpGridRowEven"');	if (this.data.headerStyle) {		aTr.push(' style="');		aTr.push(this.data.headerStyle);		aTr.push('"');	}	aTr.push('>');	// Get field number	var iFixedLeft = this.config.fixedLeft;	var aFields = this.fields;	var iFields = aFields.length;	var iShow = bFixed ? iFixedLeft : iFields;	// Check if there are spans	var bTwoRows = false;	if (!bSecondRow && aSpans.length) {		bTwoRows = true;	}	// Display fields	var iCols = aCols.length;	var bHiddenCols = (!bFixed && iFixedLeft);	var oField, oSpan, bHidden;	for (var iField = 0, iSpan = 0, iCol = 0; iField < iFields && iField < iShow;	 iField++) {		// Get field		oField = aFields[iField];		// Skip hidden columns		if (!oField || oField.hidden) {			continue;		}		// Get span		oSpan = aSpans[iField];		if (oSpan) {			iSpan += oSpan.spanned;		}		// Display field		bHidden = (bHiddenCols && iCol < iFixedLeft);		if (!bSecondRow) {			// Show all columns and spans instead of spanned columns			if (oSpan) {				// Display span				this.outputSpan(aTr, oField, iCol, oSpan, iCols, bHidden);				iCol += iSpan;				iField = oSpan.fields[oSpan.fields.length - 1].i;				iSpan = 0;			} else {				this.outputField(aTr, oField, iCol, iCols, bHidden, bTwoRows);				iCol++;			}		} else {			// Show only spanned columns			if (iSpan) {				this.outputField(aTr, oField, iCol, iCols, bHidden);				// Decrement span				iSpan--;			}			iCol++;		}	}	aTr.push('</tr>');	aHtml.push(aTr.join(''));	// Display second row if needed	if (bTwoRows) {		this.outputFieldsVert(aHtml, aCols, aSpans, aRows, bFixed, true);	}};/** * Forms grid output. *

⌨️ 快捷键说明

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