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

📄 zpgrid.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 5 页
字号:
var aCols=oArg.column;if(!(aCols instanceof Array)){aCols=[aCols];}var bApply=false;var undef;for(var iCol=0;iCol<aCols.length;iCol++){var oField=this.fields[aCols[iCol]];if(!oField){continue;}if((oField.hiddenValues instanceof Array)&&oField.hiddenValues.length){oField.hiddenValues=undef;bApply=true;}}return bApply;};Zapatec.Grid.prototype.limitRange=function(oArg){if(!oArg){return;}var oField=this.fields[oArg.column];if(!oField){return;}if(typeof oArg.min!='undefined'){oField.minValue=oArg.min;}else{if(typeof oArg.minValue=='undefined'){oField.minValue=oArg.minValue;}else{var oCell={i:oField.i,v:oArg.minValue};oCell=this.convertCell(oCell);oField.minValue=this.getCellValueCompare(oCell);}}if(typeof oArg.max!='undefined'){oField.maxValue=oArg.max;}else{if(typeof oArg.maxValue=='undefined'){oField.maxValue=oArg.maxValue;}else{var oCell={i:oField.i,v:oArg.maxValue};oCell=this.convertCell(oCell);oField.maxValue=this.getCellValueCompare(oCell);}}this.applyFilters();};Zapatec.Grid.prototype.setFilter=function(oArg){if(!oArg){oArg={};}var aFields=this.fields;var aColumns=oArg.columns;var oRegExp=oArg.regexp;var sText=oArg.text;var iCol,oField;if(aColumns instanceof Array){var iColumns=aColumns.length;for(iCol=0;iCol<iColumns;iCol++){oField=aFields[aColumns[iCol]];if(oField){oField.regexpFilter=oRegExp;oField.textFilter=sText;}}}else{var iFields=aFields.length;for(iCol=0;iCol<iFields;iCol++){oField=aFields[iCol];if(!(oField instanceof Object)){aFields[iCol]={};oField=aFields[iCol];}oField.regexpFilter=oRegExp;oField.textFilter=sText;}}this.applyFilters();};Zapatec.Grid.prototype.removeFilter=function(oArg){if(!oArg){oArg={};}this.setFilter({columns:oArg.columns});};Zapatec.Grid.prototype.resetFilters=function(){for(var iCol=0;iCol<this.fields.length;iCol++){var oField=this.fields[iCol];if(oField){var undef;oField.hiddenValues=undef;oField.minValue=undef;oField.maxValue=undef;oField.regexpFilter=undef;oField.textFilter=undef;}}this.applyFilters();this.displayFilterOut();};Zapatec.Grid.prototype.applyPaging=function(){var oConfig=this.config;var aFilteredRows=this.filteredRows;if(this.currentVerticalOffset<0){this.currentVerticalOffset=0;}var iOffset=this.currentVerticalOffset;var iVisibleRows=oConfig.visibleRows;var iRowsPerPage=oConfig.rowsPerPage;if(iRowsPerPage<=0||oConfig.dataOnDemand){if(iVisibleRows<=0){return aFilteredRows;}return aFilteredRows.slice(iOffset,iOffset+iVisibleRows);}if(this.fitInto){var oAutoresizeFrame=this.autoresizeFrame;var iFirst=oAutoresizeFrame.currentRow;var iLast=iFirst+oAutoresizeFrame.visibleRows;return aFilteredRows.slice(iFirst,iLast);}var iFirst=this.currentPage*iRowsPerPage;if(iFirst&&iFirst>=aFilteredRows.length){this.setCurrentPage(this.currentPage-1);iFirst=this.currentPage*iRowsPerPage;}var iLast=iFirst+iRowsPerPage;if(iVisibleRows<=0){return aFilteredRows.slice(iFirst,iLast);}iFirst+=iOffset;var iLastVisible=iFirst+iVisibleRows;if(iLastVisible<iLast){iLast=iLastVisible;}return aFilteredRows.slice(iFirst,iLast);};Zapatec.Grid.prototype.refresh=function(){this.fireEvent('gridPrepareRefresh');if(!this.refreshState){this.refreshState=0;}this.refreshState++;if(!this.config.visibleRows&&this.displayUpdating){this.displayUpdating();}var oGrid=this;setTimeout(function(){if(!oGrid.visualize){oGrid.refreshCallback();}else if(oGrid.refreshContainer){oGrid.refreshContainer();}},0);};Zapatec.Grid.prototype.refreshCallback=function(){this.config.callbackHeaderDisplay(this);var aRows=this.applyPaging();if(typeof this.config.callbackDataDisplay=='function'){this.config.callbackDataDisplay(this,aRows);}else{for(var iRow=0;iRow<aRows.length;iRow++){this.config.callbackRowDisplay(this,aRows[iRow]);}}if(typeof this.config.callbackTotalsDisplay=='function'||typeof this.config.callbackTotalDisplay=='function'){var aTotals;if(this.getTotals){aTotals=this.getTotals();}if(typeof this.config.callbackTotalsDisplay=='function'){this.config.callbackTotalsDisplay(this,aTotals);}else if(aTotals){var iTotals=aTotals.length;for(var iRow=0;iRow<iTotals;iRow++){this.config.callbackTotalDisplay(this,aTotals[iRow]);}}}if(this.config.rowsPerPage>0){if(typeof this.config.callbackPaginationDisplay=='function'){this.config.callbackPaginationDisplay(this);}else if(this.paginationContainers.length&&this.outputPagination){for(var iEl=0;iEl<this.paginationContainers.length;iEl++){var aHtml=[];this.outputPagination(aHtml,iEl+1);this.paginationContainers[iEl].innerHTML=aHtml.join('');}}}this.onRefresh();};Zapatec.Grid.prototype.selectRow=function(oRow){if(!oRow||oRow.selected){return;}if(typeof this.config.callbackCellSelect!='function'&&typeof this.config.callbackRowSelect=='function'){this.config.callbackRowSelect(this,oRow);}if(this.visualizeSelectRow&&this.config.selectRows&&this.visualize){this.visualizeSelectRow(oRow);}oRow.selected=true;};Zapatec.Grid.prototype.unselectRow=function(oRow){if(!oRow||!oRow.selected){return;}var undef;oRow.selected=undef;if(this.visualizeUnselectRow&&this.config.selectRows&&this.visualize){this.visualizeUnselectRow(oRow);}if(typeof this.config.callbackCellUnselect!='function'&&typeof this.config.callbackRowUnselect=='function'){this.config.callbackRowUnselect(this,oRow);}};Zapatec.Grid.prototype.selectCell=function(oCell){if(!oCell||oCell.selected){return;}if(typeof this.config.callbackCellSelect=='function'){this.config.callbackCellSelect(this,oCell);}if(this.visualizeSelectCell&&this.config.selectCells&&this.visualize){this.visualizeSelectCell(oCell);}oCell.selected=true;};Zapatec.Grid.prototype.unselectCell=function(oCell){if(!oCell||!oCell.selected){return;}var undef;oCell.selected=undef;if(this.visualizeUnselectCell&&this.config.selectCells&&this.visualize){this.visualizeUnselectCell(oCell);}if(typeof this.config.callbackCellUnselect=='function'){this.config.callbackCellUnselect(this,oCell);}};Zapatec.Grid.prototype.rowOnClick=function(iRowId,iCellId){var oRow=this.getRowById(iRowId);if(!oRow){return;}var oCell=null;if(typeof iCellId!='undefined'){oCell=this.getCellById(iRowId,iCellId);if(!oCell){return;}}var oEvent=window.event;if(oEvent.metaKey||(window.opera&&oEvent.altKey)){return;}var bShift=false;var bCtrl=false;if(this.config.multipleSelect){if(this.lastSelection){bShift=oEvent.shiftKey;}bCtrl=oEvent.ctrlKey||oEvent.metaKey;}if(!bShift&&!bCtrl){for(var iRow=0;iRow<this.rows.length;iRow++){var oCurrRow=this.rows[iRow];if(!oCurrRow||!oCurrRow.selected){continue;}if(oCell){for(var iCol=0;iCol<this.fields.length;iCol++){var oCurrCell=oCurrRow.cells[iCol];if(!oCurrCell){continue;}if(!(oCurrRow.i==iRowId&&oCurrCell.i==iCellId)){this.unselectCell(oCurrCell);}}}if(oCurrRow.i!=iRowId){this.unselectRow(oCurrRow);}}}else if(bShift){if(this.lastSelection.rows instanceof Array){for(var iRow=0;iRow<this.lastSelection.rows.length;iRow++){this.unselectRow(this.lastSelection.rows[iRow]);}}if(this.lastSelection.cells instanceof Array){for(var iCell=0;iCell<this.lastSelection.cells.length;iCell++){this.unselectCell(this.lastSelection.cells[iCell]);}}}if(oCell&&typeof this.config.callbackCellOnClick=='function'){this.config.callbackCellOnClick(this,oCell);}else if(typeof this.config.callbackRowOnClick=='function'){this.config.callbackRowOnClick(this,oRow);}if(!bShift){this.selectRow(oRow);this.lastSelection={rowId:iRowId};if(oCell){this.selectCell(oCell);this.lastSelection.cellId=iCellId;}}else{var iSelectionStartRowId=this.lastSelection.rowId;var iSelectionStartCellId=this.lastSelection.cellId;this.lastSelection.rows=[];this.lastSelection.cells=[];var aSelectedRows=this.lastSelection.rows;var aSelectedCells=this.lastSelection.cells;var iRow=0;var iLastRow=0;while(this.filteredRows[iRow]){var iCurrRowId=this.filteredRows[iRow].i;if(iCurrRowId==iRowId){iLastRow=iSelectionStartRowId;break;}else if(iCurrRowId==iSelectionStartRowId){iLastRow=iRowId;break;}iRow++;}var iFirstCell=0;var iLastCell=0;if(oCell&&typeof iSelectionStartCellId!='undefined'){if(iCellId<iSelectionStartCellId){iFirstCell=iCellId;iLastCell=iSelectionStartCellId;}else{iFirstCell=iSelectionStartCellId;iLastCell=iCellId;}}while(this.filteredRows[iRow]){var oCurrRow=this.filteredRows[iRow];if(!oCurrRow.selected){this.selectRow(oCurrRow);aSelectedRows.push(oCurrRow);}if(oCell){for(var iCell=iFirstCell;iCell<=iLastCell;iCell++){var oCurrCell=oCurrRow.cells[iCell];if(!oCurrCell.selected){this.selectCell(oCurrCell);aSelectedCells.push(oCurrCell);}}}if(oCurrRow.i==iLastRow){break;}iRow++;}}};Zapatec.Grid.rowOnClick=function(iGridId,iRowId,iCellId){var oGrid=Zapatec.Widget.getWidgetById(iGridId);if(oGrid&&oGrid.rowOnClick){oGrid.rowOnClick(iRowId,iCellId);}};Zapatec.Grid.prototype.rowOnDblClick=function(iRowId,iCellId){var oRow=this.getRowById(iRowId);if(!oRow){return;}var oCell=null;if(typeof iCellId!='undefined'){oCell=this.getCellById(iRowId,iCellId);if(!oCell){return;}}if(oCell&&typeof this.config.callbackCellOnDblClick=='function'){this.config.callbackCellOnDblClick(this,oCell);}else if(typeof this.config.callbackRowOnDblClick=='function'){this.config.callbackRowOnDblClick(this,oRow);}};Zapatec.Grid.rowOnDblClick=function(iGridId,iRowId,iCellId){var oGrid=Zapatec.Widget.getWidgetById(iGridId);if(oGrid&&oGrid.rowOnDblClick){oGrid.rowOnDblClick(iRowId,iCellId);}};Zapatec.Grid.prototype.clearSelection=function(){for(var iRow=0;iRow<this.rows.length;iRow++){var oCurrRow=this.rows[iRow];if(oCurrRow.selected){for(var iCol=0;iCol<oCurrRow.cells.length;iCol++){this.unselectCell(oCurrRow.cells[iCol]);}this.unselectRow(oCurrRow);}}};Zapatec.Grid.prototype.getSelectedRows=function(){var aSelected=[];for(var iRow=0;iRow<this.rows.length;iRow++){var oCurrRow=this.rows[iRow];if(oCurrRow.selected){aSelected.push(oCurrRow);}}return aSelected;};Zapatec.Grid.prototype.getSelectedCells=function(){var aSelected=[];for(var iRow=0;iRow<this.rows.length;iRow++){var oCurrRow=this.rows[iRow];if(oCurrRow.selected){for(var iCol=0;iCol<this.fields.length;iCol++){var oCurrCell=oCurrRow.cells[iCol];if(oCurrCell.selected){aSelected.push(oCurrCell);}}}}return aSelected;};Zapatec.Grid.prototype.getInvalidRows=function(){var aInvalid=[];for(var iRow=0;iRow<this.rows.length;iRow++){var oCurrRow=this.rows[iRow];if(oCurrRow.invalid){aInvalid.push(oCurrRow);}}return aInvalid;};Zapatec.Grid.prototype.getInvalidCells=function(){var aInvalid=[];for(var iRow=0;iRow<this.rows.length;iRow++){var oCurrRow=this.rows[iRow];if(oCurrRow.invalid){for(var iCol=0;iCol<this.fields.length;iCol++){var oCurrCell=oCurrRow.cells[iCol];if(oCurrCell.invalid){aInvalid.push(oCurrCell);}}}}return aInvalid;};Zapatec.Grid.checkboxOnClick=function(iGridId,aCols,sVal,bChecked){var oGrid=Zapatec.Widget.getWidgetById(iGridId);if(oGrid&&oGrid.filterOut){oGrid.filterOut({column:aCols,value:sVal,show:bChecked});}};Zapatec.Grid.checkboxSelectAllOnClick=function(iGridId,aCols){var oGrid=Zapatec.Widget.getWidgetById(iGridId);if(!oGrid||!oGrid.unfilterOutColumn||!oGrid.applyFilters||!oGrid.displayFilterOut){return}var bApply=oGrid.unfilterOutColumn({column:aCols});if(bApply){oGrid.applyFilters();oGrid.displayFilterOut();}};Zapatec.Grid.checkboxClearAllOnClick=function(iGridId,aCols){var oGrid=Zapatec.Widget.getWidgetById(iGridId);if(!oGrid||!oGrid.getColumnRange||!oGrid.filterOutColumn||!oGrid.applyFilters||!oGrid.displayFilterOut){return;}var oRange=oGrid.getColumnRange({column:aCols});if(!oRange){return;}var aVals=[];for(var iVal=0;iVal<oRange.values.length;iVal++){aVals.push(oRange.values[iVal].v+'');}var bApply=oGrid.filterOutColumn({column:aCols,value:aVals,show:false});if(bApply){oGrid.applyFilters();oGrid.displayFilterOut();}};Zapatec.Grid.checkboxLinkOnClick=function(iGridId,aCols,sVal){var oGrid=Zapatec.Widget.getWidgetById(iGridId);if(!oGrid||!oGrid.getColumnRange||!oGrid.filterOutColumn||!oGrid.applyFilters||!oGrid.displayFilterOut){return;}var oRange=oGrid.getColumnRange({column:aCols});if(!oRange){return;}var aVals=[];for(var iVal=0;iVal<oRange.values.length;iVal++){aVals.push(oRange.values[iVal].v+'');}var bClear=oGrid.filterOutColumn({column:aCols,value:aVals,show:false});var bShow=oGrid.filterOutColumn({column:aCols,value:sVal,show:true});if(bClear||bShow){oGrid.applyFilters();oGrid.displayFilterOut();}};Zapatec.Grid.prototype.addFilterOut=function(oArg){this.filterOutRules.push(oArg);};Zapatec.Grid.prototype.displayFilterOut=function(){var aFilterOutRules=this.filterOutRules;var iFilterOutRules=aFilterOutRules.length;for(var iFo=0;iFo<iFilterOutRules;iFo++){var oFilterOut=aFilterOutRules[iFo];var oRange=this.getColumnRange(oFilterOut);if(!oRange){continue;}var aVals=oRange.values;if(oFilterOut.sortDesc){aVals.sort(function(leftVal,rightVal){if(leftVal.c<rightVal.c){return 1;}if(leftVal.c>rightVal.c){return-1;}return 0;});}if(typeof oFilterOut.callback=='function'){var aCols=oFilterOut.column;if(!(aCols instanceof Array)){aCols=[aCols];}var aFields=[];for(var iCol=0;iCol<aCols.length;iCol++){var oField=this.fields[aCols[iCol]];if(!oField){continue;}aFields.push(oField);}if(!aFields.length){continue;}var sCols=aCols.join(',');var aChoices=[];for(var iVal=0;iVal<aVals.length;iVal++){var sVal=aVals[iVal].v+'';var sEscaped=escape(sVal);var oChoice={};oChoice.value=sVal;oChoice.onclick="Zapatec.Grid.checkboxOnClick('"+this.id+"',["+sCols+"],unescape('"+sEscaped+"'),this.checked)";oChoice.checked=false;for(var iField=0;iField<aFields.length;iField++){var oField=aFields[iField];if(!(oField.hiddenValues instanceof Array)||Zapatec.Utils.arrIndexOf(oField.hiddenValues,sVal)<0){oChoice.checked=true;break;}}oChoice.link="Zapatec.Grid.checkboxLinkOnClick('"+this.id+"',["+sCols+"],unescape('"+sEscaped+"'))";if(iVal==0){oChoice.selectall="Zapatec.Grid.checkboxSelectAllOnClick('"+

⌨️ 快捷键说明

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