📄 zpgrid-output.js
字号:
* @private * @param {object} aHtml Output array * @param {number} oField Field object * @param {number} iCol Visible column number * @param {number} oSpan Number of spanned columns, span title and style * @param {number} iCols Visible column count * @param {boolean} bHidden (Optional) Indicates that this is hidden part of * fixed part of header */Zapatec.Grid.prototype.outputSpan = function(aHtml, oField, iCol, oSpan, iCols, bHidden) { var aCl = []; aCl.push('zpGridCell zpGridCell'); aCl.push(iCol); aCl.push(' zpGridField zpGridField'); aCl.push(iCol); aCl.push(' zpGridFieldSpan zpGridFieldSpan'); aCl.push(iCol); aCl.push(' zpGridColId'); aCl.push(oSpan.fields[0].i); if (iCol % 2 == 1) { aCl.push(' zpGridCellOdd zpGridFieldOdd zpGridFieldSpanOdd'); } else { aCl.push(' zpGridCellEven zpGridFieldEven zpGridFieldSpanEven'); } if (iCol + oSpan.spanned == iCols) { aCl.push(' zpGridCellLast zpGridFieldLast zpGridFieldSpanLast'); } var sClass = aCl.join(''); aCl.push(' zpGridCellActive zpGridCellActive'); aCl.push(iCol); aCl.push(' zpGridFieldActive zpGridFieldActive'); aCl.push(iCol); aCl.push(' zpGridFieldSpanActive zpGridFieldSpanActive'); aCl.push(iCol); if (iCol % 2 == 1) { aCl.push( ' zpGridCellActiveOdd zpGridFieldActiveOdd zpGridFieldSpanActiveOdd'); } else { aCl.push( ' zpGridCellActiveEven zpGridFieldActiveEven zpGridFieldSpanActiveEven'); } if (iCol + oSpan.spanned == iCols) { aCl.push( ' zpGridCellActiveLast zpGridFieldActiveLast zpGridFieldSpanActiveLast'); } var sClassActive = aCl.join(''); var aTd = []; if (this.config.horizontal) { aTd.push('<td rowspan="'); } else { aTd.push('<td colspan="'); } aTd.push(oSpan.spanned); aTd.push('" class="'); aTd.push(sClass); aTd.push('" id="zpGrid'); aTd.push(this.id); aTd.push('Span'); aTd.push(oSpan.fields[0].i); if (bHidden) { aTd.push('Hidden'); } else { aTd.push('" onmouseover="this.className=\''); aTd.push(sClassActive); aTd.push('\'" onmouseout="this.className=\''); aTd.push(sClass); aTd.push("'"); } if (oSpan.fields[0].spanStyle) { aTd.push('" style="'); aTd.push(oSpan.fields[0].spanStyle); } // Resizing aTd.push('"><div style="position:relative;overflow:visible">'); // No need to resize hidden part of the grid if (!bHidden) { // Resizing is implemented only for vertical layout if (!this.config.horizontal) { aTd.push('<div id="zpGrid'); aTd.push(this.id); aTd.push('Span'); aTd.push(oField.i); aTd.push('Margin" class="zpGridColMargin"></div><div id="zpGrid'); aTd.push(this.id); aTd.push('Span'); aTd.push(oField.i); // "return false" stops selection in Opera aTd.push('Resize" onmousedown="Zapatec.Drag.start(window.event,this.id,{horizontal:true,limitLeft:10});return false" class="zpGridColResizeHidden"></div>'); } } aTd.push('<span class="zpGridSpan">'); aTd.push(oSpan.fields[0].spanTitle); aTd.push('</span></div></td>'); aHtml.push(aTd.join(''));};/** * Forms grid output. * * @private * @param {object} aHtml Output array * @param {number} oField Field object * @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 header * @param {boolean} bTwoRows (Optional) Indicates that this cell spans two * rows */Zapatec.Grid.prototype.outputField = function(aHtml, oField, iCol, iCols, bHidden, bTwoRows) { if (oField.i >= this.config.fixedLeft && oField.i < this.currentHorizontalOffset + this.config.fixedLeft) { // Hidden column return; } if (this.config.visibleColumns) { bHidden = false; } var sId = this.id.toString(); var sFieldId = oField.i.toString(); var aCl = []; aCl.push('zpGridCell zpGridCell'); aCl.push(iCol); aCl.push(' zpGridField zpGridField'); aCl.push(iCol); aCl.push(' zpGridColId'); aCl.push(sFieldId); if (iCol % 2 == 1) { aCl.push(' zpGridCellOdd zpGridFieldOdd'); } else { aCl.push(' zpGridCellEven zpGridFieldEven'); } if (iCol == iCols - 1) { aCl.push(' zpGridCellLast zpGridFieldLast'); } if (!oField.nosort) { if (oField.sorted) { aCl.push(' zpGridSortedAsc'); } else if (oField.sortedDesc) { aCl.push(' zpGridSortedDesc'); } } var sClass = aCl.join(''); aCl.push(' zpGridCellActive zpGridCellActive'); aCl.push(iCol); aCl.push(' zpGridFieldActive zpGridFieldActive'); aCl.push(iCol); if (iCol % 2 == 1) { aCl.push(' zpGridCellActiveOdd zpGridFieldActiveOdd'); } else { aCl.push(' zpGridCellActiveEven zpGridFieldActiveEven'); } if (iCol == iCols - 1) { aCl.push(' zpGridCellActiveLast zpGridFieldActiveLast'); } if (!oField.nosort) { if (oField.sorted) { aCl.push(' zpGridSortedAscActive'); } else if (oField.sortedDesc) { aCl.push(' zpGridSortedDescActive'); } } var sClassActive = aCl.join(''); var aTd = []; aTd.push('<td'); if (bTwoRows) { if (this.config.horizontal) { aTd.push(' colspan="2"'); } else { aTd.push(' rowspan="2"'); } } aTd.push(' class="'); aTd.push(sClass); aTd.push('" id="zpGrid'); aTd.push(sId); aTd.push('Field'); aTd.push(sFieldId); if (bHidden) { aTd.push('Hidden'); } else { aTd.push('" onmouseover="this.className=\''); aTd.push(sClassActive); aTd.push('\'" onmouseout="this.className=\''); aTd.push(sClass); aTd.push("'"); if (!oField.nosort) { aTd.push('" onclick="Zapatec.Grid.sort(\''); aTd.push(sId); aTd.push("','"); aTd.push(sFieldId); aTd.push("')"); } aTd.push('" onmousedown="Zapatec.Widget.callMethod('); aTd.push(sId); aTd.push(",'fireEvent','gridFieldMousedown',"); aTd.push(sFieldId); aTd.push(')'); aTd.push('" onmouseup="Zapatec.Widget.callMethod('); aTd.push(sId); aTd.push(",'fireEvent','gridFieldMouseup',"); aTd.push(sFieldId); aTd.push(')'); } if (oField.style) { aTd.push('" style="'); aTd.push(oField.style); } // div is needed to be able to set column width // span is needed to be able to set right margin for arrow // Resizing aTd.push('"><div style="position:relative;overflow:visible">'); // No need to resize hidden part of the grid if (!bHidden) { // Resizing is implemented only for vertical layout if (!this.config.horizontal) { aTd.push('<div id="zpGrid'); aTd.push(sId); aTd.push('Col'); aTd.push(sFieldId); aTd.push('Margin" class="zpGridColMargin"></div><div id="zpGrid'); aTd.push(sId); aTd.push('Col'); aTd.push(sFieldId); // "return false" stops selection in Opera aTd.push('Resize" onmousedown="Zapatec.Drag.start(window.event,this.id,{horizontal:true,limitLeft:10});return false" class="zpGridColResizeHidden"></div>'); } } aTd.push('<div class="zpGridDiv'); if (bTwoRows) { aTd.push(' zpGridSpannedDiv'); } // Set cell type if (this.getClassByType) { aTd.push(' '); aTd.push(this.getClassByType(this.getFieldType(oField))); } aTd.push('" id="zpGrid'); aTd.push(sId); aTd.push('Col'); aTd.push(sFieldId); aTd.push('Title'); if (bHidden) { aTd.push('Hidden'); } aTd.push('"><span class="zpGridSpan" onselectstart="return false" style="-moz-user-select:none" id="zpGrid'); aTd.push(sId); aTd.push('Col'); aTd.push(sFieldId); aTd.push('Title'); if (bHidden) { aTd.push('Hidden'); } aTd.push('Span">'); aTd.push(oField.title); aTd.push('</span></div></div></td>'); aHtml.push(aTd.join(''));};/** * 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 table * @param {object} oContr Optional. Data container */Zapatec.Grid.prototype.outputRows = function(aHtml, aCols, aFixedCols, aSpans, aRows, aTotals, bFixed, oContr) { if (this.config.horizontal) { // Horizontal layout this.outputRowsHoriz(aHtml, aCols, aFixedCols, aSpans, aRows, aTotals, bFixed); } else { // Vertical layout this.outputRowsVert(aHtml, aCols, aFixedCols, aRows, bFixed, oContr); // Totals if (aTotals && !this.totalsContainer && this.outputTotals) { this.outputTotals(aHtml, aCols, aFixedCols, aTotals, 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 row */Zapatec.Grid.prototype.outputRowsHoriz = function(aHtml, aCols, aFixedCols, aSpans, aRows, aTotals, bFixed) { var iSpanned = 0; var iCols = aCols.length; var iSpans = aSpans.length; var iRows = aRows.length; var iTotals = 0; if (aTotals && !this.totalsContainer && this.outputTotalsCell) { iTotals = aTotals.length; } // Skip fixed columns because they are already displayed in header var iCol, oField, aCl, sClass, aTr, oSpan, iRow; for (iCol = aFixedCols.length; iCol < iCols; iCol++) { // Get field object oField = aCols[iCol]; aCl = []; aCl.push('zpGridCol zpGridCol'); aCl.push(iCol); if (iCol % 2 == 1) { aCl.push(' zpGridColOdd'); } else { aCl.push(' zpGridColEven'); } if (iCol == iCols - 1) { aCl.push(' zpGridColLast'); } 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); 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} aFixedCols Array with fixed field objects to output * @param {object} aRows Array with row objects to output * @param {boolean} bFixed Optional. Indicates that this is fixed part of row * @param {object} oContr Optional. Data container */Zapatec.Grid.prototype.outputRowsVert = function(aHtml, aCols, aFixedCols, aRows, bFixed, oContr) { var iRows = aRows.length; var iRow, oRow; for (iRow = 0; iRow <= iRows; iRow++) { oRow = aRows[iRow]; if (!oRow) { continue; } this.outputRowVert(aHtml, aCols, aFixedCols, aRows, iRow, bFixed, oContr); }};/** * 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} aRows Array with row objects to output * @param {object} iRow Number of row on the page * @param {boolean} bFixed Optional. Indicates that this is fixed part of row * @param {object} oContr Optional. Data container */Zapatec.Grid.prototype.outputRowVert = function(aHtml, aCols, aFixedCols, aRows, iRow, bFixed, oContr) { // Get row var oRow = aRows[iRow]; if (!oRow) { return; } // Form tr var iRows = aRows.length; var iCols = aCols.length; var iFixedCols = aFixedCols.length; var aCl = []; var iRowN = iRow + 1; var sOdd = iRowN % 2 == 1 ? 'Odd' : 'Even'; aCl.push('zpGridRow zpGridRow'); aCl.push(iRowN); aCl.push(' zpGridDataRow zpGridDataRow'); aCl.push(iRowN); aCl.push(' zpGridRow'); aCl.push(sOdd); aCl.push(' zpGridDataRow'); aCl.push(sOdd); if (iRowN == iRows) { aCl.push(' zpGridRowLast zpGridDataRowLast'); } if (this.config.selectRows && oRow.selected) { aCl.push(' zpGridRowSelected zpGridRowSelected'); aCl.push(iRowN); aCl.push(' zpGridRowSelected'); aCl.push(sOdd); if (iRowN == iRows) { aCl.push(' zpGridRowSelectedLast'); } } if (oRow.invalid) { aCl.push(' zpGridRowInvalid zpGridRowInvalid'); aCl.push(iRowN); aCl.push(' zpGridRowInvalid'); aCl.push(iRowN % 2 == 1 ? 'Odd' : 'Even'); if (iRowN == iRows) { aCl.push(' zpGridRowInvalidLast'); } } var sClass = aCl.join(''); var aClA = []; aClA.push(' zpGridRowActive zpGridRowActive'); aClA.push(iRowN); aClA.push(' zpGridRowActive'); aClA.push(iRowN % 2 == 1 ? 'Odd' : 'Even'); if (iRowN == iRows) { aClA.push(' zpGridRowActiveLast'); } var sClassActive = aClA.join(''); var aTr = []; aTr.push('<tr id="zpGrid'); aTr.push(this.id); aTr.push('Row'); aTr.push(oRow.i);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -