📄 grids.js
字号:
{ this._parent._currentDragHeader._onMouseUp(e); return; } if (this._resizeDir != "") return; if (this._sortable) { this._setDownState(false); } if (!this._parent._columnDragged && !this._parent._columnResized && this._sortable) { var oldAscending = this._ascending; var newAscending = oldAscending == null ? true : !oldAscending; if (this._parent.getSortColumn() == this._columnIndex) this._parent.setAscending(newAscending); else { this._parent._ascending = newAscending; this._parent.setSortColumn(this._columnIndex); } }};_p._onMouseMove = function(e){ var p = this.getParent(); var visualIndex = p._invertedColumnOrders[this._columnIndex]; var previousIndex = p._columnOrders[visualIndex - 1]; var ps = p._children[previousIndex]; if (!this._resizable && (ps == null || !ps._resizable)) return; if (p._currentDragHeader) this._resizeDir = ""; else if (e.getOffsetX() <= 8 && ps) this._resizeDir = "w"; else if (e.getOffsetX() + 8 >= this.getWidth()) this._resizeDir = "e"; else this._resizeDir = ""; if (this._resizeDir != "") { if (( new BiBrowserCheck).getIe55()) this.setCursor("hand"); else if (( new BiBrowserCheck).getIe()) this.setCursor("col-resize"); else this.setCursor("e-resize"); } else this.setCursor("");};function BiGridHeaderFiller(){ BiGridHeader.call(this);};var _p = BiGridHeaderFiller.prototype = new BiGridHeader;_p._className = "BiGridHeaderFiller";_p._sortable = false;_p._resizable = false;_p._movable = false;_p._normalBorder = new BiBorder(1, "solid", "ThreeDShadow");_p._normalBorder.setTopColor("ThreeDHighlight");_p._normalBorder.setLeftColor("ThreeDHighlight");_p._normalBorder.setRightWidth(0);function BiGridHeaderCorner(){ BiGridHeader.call(this); this.setLocation(0, 0); this.setRight(null); this.setBottom(null);}var _p = BiGridHeaderCorner.prototype = new BiGridHeader;_p._className = "BiGridHeaderCorner";_p._sortable = false;_p._resizable = false;_p._movable = false;_p._normalBorder = new BiBorder(1, "solid", "ThreeDShadow");_p._normalBorder.setTopColor("ThreeDHighlight");_p._normalBorder.setLeftColor("ThreeDHighlight");function BiGridRowHeaders(){ BiComponent.call(this); this.setCssClassName("bi-grid-row-headers");}var _p = BiGridRowHeaders.prototype = new BiComponent;_p._className = "BiGridRowHeaders";_p._rowHeight = 18;_p._setHeadersHtml = function(s){ if (this.getCreated()) { this._element.innerHTML = s + "<div class=\"bi-grid-row-header-filler\"></div>"; }};function BiAbstractGrid(){ BiComponent.call(this); this.setTabIndex(1); this.setHideFocus(true); this._rows = []; this._nodes = this._rows; this._gridElements = { }; this._columns = []; this._columnOrders = []; this._invertedColumnOrders = []; this._columnWidths = []; this._columnNames = []; this._columnAligns = []; this._columnSortTypes = []; this.setSize(300, 300);}var _p = BiAbstractGrid.prototype = new BiComponent;_p._className = "BiAbstractGrid";_p._gridHeadersConstructor = BiGridHeaders;_p._gridColumnConstructor = BiGridColumn;_p._lastKeyPress = 0;_p._accumulatedKeys = "";_p._columnCount = 0;_p._columns = null;_p._columnOrders = null;_p._invertedColumnOrders = null;_p._columnWidths = null;_p._columnNames = null;_p._columnAligns = null;_p._columnSortTypes = null;_p._iconColumn = -1;_p._showHeaders = true;_p._showRowHeaders = false;_p._liveResize = false;_p._sortColumn = -1;_p._ascending = null;_p._selectionModel = null;_p._allNodes = null;_p._gridCreated = false;_p._rowHeight = 18;_p._fontSize = 11;_p._rowHeadersWidth = 30;_p._headersHeight = 18;_p._overflowX = "auto";_p._overflowY = "auto";BiAbstractGrid.prototype.getColumns = function(){ return this._columns;} ;BiAbstractGrid.prototype.getShowHeaders = function(){ return this._showHeaders;} ;BiAbstractGrid.prototype.setShowHeaders = function(v){ this._showHeaders = v;} ;BiAbstractGrid.prototype.getShowRowHeaders = function(){ return this._showRowHeaders;} ;BiAbstractGrid.prototype.setShowRowHeaders = function(v){ this._showRowHeaders = v;} ;BiAbstractGrid.prototype.getRowHeadersWidth = function(){ return this._rowHeadersWidth;} ;BiAbstractGrid.prototype.setRowHeadersWidth = function(v){ this._rowHeadersWidth = v;} ;BiAbstractGrid.prototype.getHeadersHeight = function(){ return this._headersHeight;} ;BiAbstractGrid.prototype.setHeadersHeight = function(v){ this._headersHeight = v;} ;BiAbstractGrid.prototype.getLiveResize = function(){ return this._liveResize;} ;BiAbstractGrid.prototype.getSortColumn = function(){ return this._sortColumn;} ;BiAbstractGrid.prototype.getAscending = function(){ return this._ascending;} ;BiAbstractGrid.prototype.getSelectionModel = function(){ return this._selectionModel;} ;BiAbstractGrid.prototype.getRowHeight = function(){ return this._rowHeight;} ;BiAbstractGrid.prototype.setRowHeight = function(v){ this._rowHeight = v;} ;_p._getFillerHeight = function(){ return this._showHeaders ? this._headersHeight : 0;} ;_p._getFillerWidth = function(){ return this._showRowHeaders ? this._rowHeadersWidth : 0;} ;_p.layoutAllChildren = function(){ this._layoutHeadersX(); this._layoutHeadersY(); BiComponent.prototype.layoutAllChildren.call(this);};_p.layoutAllChildrenX = function(){ this._layoutHeadersX(); BiComponent.prototype.layoutAllChildrenX.call(this);};_p.layoutAllChildrenY = function(){ this._layoutHeadersY(); BiComponent.prototype.layoutAllChildrenY.call(this);};_p.setColumnCount = function(n){ if (this._columnCount > n) { for (var i = n; i < this._columnCount; i++) { this._headers.remove(this._columns[i].getHeader()); this._columns[i].dispose(); } this._columns = this._columns.slice(0, n); } else { var c; for (var i = this._columnCount; i < n; i++) { c = this._columns[i] = new this._gridColumnConstructor(this._columnNames[i]); c._columnIndex = i; c._orderIndex = i; c._grid = this; c.setAlign(this._columnAligns[i]); this._headers.add(c.getHeader()); } this.setColumnOrders(BiAbstractGrid._expandArray2(this._columnOrders, n)); this.setColumnWidths(BiAbstractGrid._expandArray(this._columnWidths, n, 100)); this.setColumnNames(BiAbstractGrid._expandArray(this._columnNames, n, "Untitled")); this.setColumnAligns(BiAbstractGrid._expandArray(this._columnAligns, n, "left")); this.setColumnSortTypes(BiAbstractGrid._expandArray(this._columnSortTypes, n, "string")); } this._columnCount = n; this._headers.setColumnCount(n);};BiAbstractGrid._expandArray = function(a, n, v){ for (var i = a.length; i < n; i++) a[i] = v; return a;};BiAbstractGrid._expandArray2 = function(a, n){ for (var i = a.length; i < n; i++) a[i] = i; return a;};BiAbstractGrid.prototype.getColumnCount = function(){ return this._columnCount;} ;_p.setColumnWidths = function(aWidths){ this._columnWidths = aWidths; for (var i = 0; i < this._columnCount; i++) { this._columns[i].setWidth(aWidths[i]); } this._headers.setColumnWidths(aWidths);};BiAbstractGrid.prototype.getColumnWidths = function(){ return this._columnWidths;} ;_p.getColumnWidth = function(x){ return this._columns[x].getWidth();} ;_p.setColumnOrders = function(aOrderIndexes){ this._columnOrders = aOrderIndexes; for (var i = 0; i < this._columnCount; i++) { this._columns[aOrderIndexes[i]]._orderIndex = i; } this._invertedColumnOrders = new Array(aOrderIndexes.length); for (var i = 0; i < aOrderIndexes.length; i++) { this._invertedColumnOrders[aOrderIndexes[i]] = i; } this._headers.setColumnOrders(aOrderIndexes);};BiAbstractGrid.prototype.getColumnOrders = function(){ return this._columnOrders;} ;_p.getColumnOrder = function(x){ return this._columns[x].getOrderIndex();} ;_p.setColumnAligns = function(aAligns){ this._columnAligns = aAligns; for (var i = 0; i < this._columnCount; i++) { this._columns[i].setAlign(aAligns[i]); }};BiAbstractGrid.prototype.getColumnAligns = function(){ return this._columnAligns;} ;_p.getColumnAlign = function(x){ return this._columns[x].getAlign();} ;_p.setColumnNames = function(aNames){ this._columnNames = aNames; for (var i = 0; i < this._columnCount; i++) { this._columns[i].setName(aNames[i]); }};BiAbstractGrid.prototype.getColumnNames = function(){ return this._columnNames;} ;_p.getColumnName = function(x){ return this._columns[x].getName();} ;_p.setColumnSortTypes = function(aSortTypes){ this._columnSortTypes = aSortTypes; for (var i = 0; i < this._columnCount; i++) { this._columns[i].setSortType(aSortTypes[i]); }};BiAbstractGrid.prototype.getColumnSortTypes = function(){ return this._columnSortTypes;} ;_p.getColumnSortType = function(x){ return this._columns[x].getSortType();} ;BiAbstractGrid.prototype.getIconColumn = function(){ return this._iconColumn;} ;_p.setIconColumn = function(n){ if (this._columns[this._iconColumn]) this._columns[this._iconColumn]._iconColumn = false; this._iconColumn = n; if (this._columns[this._iconColumn]) this._columns[this._iconColumn]._iconColumn = true;};_p.setFitColumnWidths = function(b){ this._headers.setFitColumnWidths(b); this.setOverflowX(b ? "hidden" : "auto");};_p.getFitColumnWidths = function(){ return this._headers.getFitColumnWidths();} ;_p.setLiveResize = function(b){ if (this._liveResize != b) { if (b) this._headers.addEventListener("columnwidthschanging", this.updateColumns, this); else this._headers.removeEventListener("columnwidthschanging", this.updateColumns, this); this._liveResize = b; }};_p.setShowHeaders = function(b){ if (this._showHeaders != b) { this._showHeaders = b; this._headers.setVisible(b); if (this._headerCorner) this._headerCorner.setVisible(this.getShowHeaders() && this.getShowRowHeaders()); if (this.getCreated()) this._gridBodyElement.style.paddingTop = this._getFillerHeight() + "px"; this._headers.setLeft(this._getFillerWidth()); if (this._rowHeaders) { this._rowHeaders.setTop(this._getFillerHeight()); this._updateRowHeadersHeight(); } if (b) this.updateHeadersWidth(); }};_p.setHeadersHeight = function(n){ if (this._headersHeight != n) { this._headersHeight = n; if (this.getCreated()) this._gridBodyElement.style.paddingTop = this._getFillerHeight() + "px"; if (this._rowHeaders) { this._rowHeaders.setTop(this._getFillerHeight()); this._updateRowHeadersHeight(); } }};_p.update = function(){ this.updateColumns(); this.updateData();};_p.updateColumns = function(){ if (this.getCreated()) { this._removeStyleRules(); var rs = this._getStyleRules(); var l = rs.length; if (BiBrowserCheck.ie) { for (var i = 0; i < l; i++) this._styleSheet.addRule(rs[i].selector, rs[i].style); } else { for (var i = 0; i < l; i++) this._styleSheet.insertRule(rs[i].selector + "{" + rs[i].style + "}", this._styleSheet.cssRules.length); } this.updateHeadersWidth(); }};_p._removeStyleRules = function(){ if (this._styleSheet) { var rules; if (BiBrowserCheck.ie) rules = this._styleSheet.rules; else rules = this._styleSheet.cssRules; var l = rules.length; var s = "#" + this.getHtmlProperty("id"); if (BiBrowserCheck.ie) { for (var i = rules.length - 1; i >= 0; i--) { if (rules[i].selectorText.indexOf(s) == 0) { this._styleSheet.removeRule(i); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -