|
|
@ -130,99 +130,99 @@ BI.GridView = BI.inherit(BI.Widget, { |
|
|
|
var visibleColumnIndices = this._columnSizeAndPositionManager.getVisibleCellRange(width, scrollLeft); |
|
|
|
var visibleColumnIndices = this._columnSizeAndPositionManager.getVisibleCellRange(width, scrollLeft); |
|
|
|
var visibleRowIndices = this._rowSizeAndPositionManager.getVisibleCellRange(height, scrollTop); |
|
|
|
var visibleRowIndices = this._rowSizeAndPositionManager.getVisibleCellRange(height, scrollTop); |
|
|
|
|
|
|
|
|
|
|
|
if (BI.isEmpty(visibleColumnIndices) || BI.isEmpty(visibleRowIndices)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft); |
|
|
|
|
|
|
|
var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._renderedColumnStartIndex = visibleColumnIndices.start; |
|
|
|
|
|
|
|
this._renderedColumnStopIndex = visibleColumnIndices.stop; |
|
|
|
|
|
|
|
this._renderedRowStartIndex = visibleRowIndices.start; |
|
|
|
|
|
|
|
this._renderedRowStopIndex = visibleRowIndices.stop; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var overscanColumnIndices = this._getOverscanIndices(this.columnCount, overscanColumnCount, this._renderedColumnStartIndex, this._renderedColumnStopIndex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var overscanRowIndices = this._getOverscanIndices(this.rowCount, overscanRowCount, this._renderedRowStartIndex, this._renderedRowStopIndex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var columnStartIndex = overscanColumnIndices.overscanStartIndex; |
|
|
|
|
|
|
|
var columnStopIndex = overscanColumnIndices.overscanStopIndex; |
|
|
|
|
|
|
|
var rowStartIndex = overscanRowIndices.overscanStartIndex; |
|
|
|
|
|
|
|
var rowStopIndex = overscanRowIndices.overscanStopIndex; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 算区间size
|
|
|
|
|
|
|
|
var minRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStartIndex); |
|
|
|
|
|
|
|
var minColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStartIndex); |
|
|
|
|
|
|
|
var maxRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStopIndex); |
|
|
|
|
|
|
|
var maxColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStopIndex); |
|
|
|
|
|
|
|
var top = minRowDatum.offset + verticalOffsetAdjustment; |
|
|
|
|
|
|
|
var left = minColumnDatum.offset + horizontalOffsetAdjustment; |
|
|
|
|
|
|
|
var bottom = maxRowDatum.offset + verticalOffsetAdjustment + maxRowDatum.size; |
|
|
|
|
|
|
|
var right = maxColumnDatum.offset + horizontalOffsetAdjustment + maxColumnDatum.size; |
|
|
|
|
|
|
|
// 如果滚动的区间并没有超出渲染的范围
|
|
|
|
|
|
|
|
if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var renderedCells = [], renderedKeys = {}, renderedWidgets = {}; |
|
|
|
var renderedCells = [], renderedKeys = {}, renderedWidgets = {}; |
|
|
|
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; |
|
|
|
// 没有可见的单元格就干掉所有渲染过的
|
|
|
|
var count = 0; |
|
|
|
if (!BI.isEmpty(visibleColumnIndices) && !BI.isEmpty(visibleRowIndices)) { |
|
|
|
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { |
|
|
|
var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft); |
|
|
|
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); |
|
|
|
var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop); |
|
|
|
|
|
|
|
|
|
|
|
for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) { |
|
|
|
this._renderedColumnStartIndex = visibleColumnIndices.start; |
|
|
|
var key = rowIndex + "-" + columnIndex; |
|
|
|
this._renderedColumnStopIndex = visibleColumnIndices.stop; |
|
|
|
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); |
|
|
|
this._renderedRowStartIndex = visibleRowIndices.start; |
|
|
|
|
|
|
|
this._renderedRowStopIndex = visibleRowIndices.stop; |
|
|
|
var index = this.renderedKeys[key] && this.renderedKeys[key][2]; |
|
|
|
|
|
|
|
var child; |
|
|
|
var overscanColumnIndices = this._getOverscanIndices(this.columnCount, overscanColumnCount, this._renderedColumnStartIndex, this._renderedColumnStopIndex); |
|
|
|
if (index >= 0) { |
|
|
|
|
|
|
|
// if (columnDatum.size !== this.renderedCells[index]._width) {
|
|
|
|
var overscanRowIndices = this._getOverscanIndices(this.rowCount, overscanRowCount, this._renderedRowStartIndex, this._renderedRowStopIndex); |
|
|
|
// this.renderedCells[index]._width = columnDatum.size;
|
|
|
|
|
|
|
|
this.renderedCells[index].el.setWidth(columnDatum.size); |
|
|
|
var columnStartIndex = overscanColumnIndices.overscanStartIndex; |
|
|
|
// }
|
|
|
|
var columnStopIndex = overscanColumnIndices.overscanStopIndex; |
|
|
|
// if (rowDatum.size !== this.renderedCells[index]._height) {
|
|
|
|
var rowStartIndex = overscanRowIndices.overscanStartIndex; |
|
|
|
// this.renderedCells[index]._height = rowDatum.size;
|
|
|
|
var rowStopIndex = overscanRowIndices.overscanStopIndex; |
|
|
|
this.renderedCells[index].el.setHeight(rowDatum.size); |
|
|
|
|
|
|
|
// }
|
|
|
|
// 算区间size
|
|
|
|
// if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) {
|
|
|
|
var minRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStartIndex); |
|
|
|
this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); |
|
|
|
var minColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStartIndex); |
|
|
|
// }
|
|
|
|
var maxRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStopIndex); |
|
|
|
// if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
|
|
|
|
var maxColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStopIndex); |
|
|
|
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); |
|
|
|
var top = minRowDatum.offset + verticalOffsetAdjustment; |
|
|
|
// }
|
|
|
|
var left = minColumnDatum.offset + horizontalOffsetAdjustment; |
|
|
|
child = this.renderedCells[index].el; |
|
|
|
var bottom = maxRowDatum.offset + verticalOffsetAdjustment + maxRowDatum.size; |
|
|
|
renderedCells.push(this.renderedCells[index]); |
|
|
|
var right = maxColumnDatum.offset + horizontalOffsetAdjustment + maxColumnDatum.size; |
|
|
|
} else { |
|
|
|
// 如果滚动的区间并没有超出渲染的范围
|
|
|
|
var item = o.itemFormatter(o.items[rowIndex][columnIndex], rowIndex, columnIndex); |
|
|
|
if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) { |
|
|
|
child = BI._lazyCreateWidget(BI.extend({ |
|
|
|
return; |
|
|
|
type: "bi.label", |
|
|
|
} |
|
|
|
width: columnDatum.size, |
|
|
|
|
|
|
|
height: rowDatum.size |
|
|
|
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; |
|
|
|
}, item, { |
|
|
|
var count = 0; |
|
|
|
cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""), |
|
|
|
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { |
|
|
|
_rowIndex: rowIndex, |
|
|
|
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); |
|
|
|
_columnIndex: columnIndex, |
|
|
|
|
|
|
|
_left: columnDatum.offset + horizontalOffsetAdjustment, |
|
|
|
for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) { |
|
|
|
_top: rowDatum.offset + verticalOffsetAdjustment |
|
|
|
var key = rowIndex + "-" + columnIndex; |
|
|
|
}), this); |
|
|
|
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); |
|
|
|
renderedCells.push({ |
|
|
|
|
|
|
|
el: child, |
|
|
|
var index = this.renderedKeys[key] && this.renderedKeys[key][2]; |
|
|
|
left: columnDatum.offset + horizontalOffsetAdjustment, |
|
|
|
var child; |
|
|
|
top: rowDatum.offset + verticalOffsetAdjustment, |
|
|
|
if (index >= 0) { |
|
|
|
_left: columnDatum.offset + horizontalOffsetAdjustment, |
|
|
|
// if (columnDatum.size !== this.renderedCells[index]._width) {
|
|
|
|
_top: rowDatum.offset + verticalOffsetAdjustment |
|
|
|
// this.renderedCells[index]._width = columnDatum.size;
|
|
|
|
// _width: columnDatum.size,
|
|
|
|
this.renderedCells[index].el.setWidth(columnDatum.size); |
|
|
|
// _height: rowDatum.size
|
|
|
|
// }
|
|
|
|
}); |
|
|
|
// if (rowDatum.size !== this.renderedCells[index]._height) {
|
|
|
|
|
|
|
|
// this.renderedCells[index]._height = rowDatum.size;
|
|
|
|
|
|
|
|
this.renderedCells[index].el.setHeight(rowDatum.size); |
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) {
|
|
|
|
|
|
|
|
this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); |
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
|
|
|
|
|
|
|
|
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) / BI.pixRatio + BI.pixUnit); |
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
child = this.renderedCells[index].el; |
|
|
|
|
|
|
|
renderedCells.push(this.renderedCells[index]); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
var item = o.itemFormatter(o.items[rowIndex][columnIndex], rowIndex, columnIndex); |
|
|
|
|
|
|
|
child = BI._lazyCreateWidget(BI.extend({ |
|
|
|
|
|
|
|
type: "bi.label", |
|
|
|
|
|
|
|
width: columnDatum.size, |
|
|
|
|
|
|
|
height: rowDatum.size |
|
|
|
|
|
|
|
}, item, { |
|
|
|
|
|
|
|
cls: (item.cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""), |
|
|
|
|
|
|
|
_rowIndex: rowIndex, |
|
|
|
|
|
|
|
_columnIndex: columnIndex, |
|
|
|
|
|
|
|
_left: columnDatum.offset + horizontalOffsetAdjustment, |
|
|
|
|
|
|
|
_top: rowDatum.offset + verticalOffsetAdjustment |
|
|
|
|
|
|
|
}), this); |
|
|
|
|
|
|
|
renderedCells.push({ |
|
|
|
|
|
|
|
el: child, |
|
|
|
|
|
|
|
left: columnDatum.offset + horizontalOffsetAdjustment, |
|
|
|
|
|
|
|
top: rowDatum.offset + verticalOffsetAdjustment, |
|
|
|
|
|
|
|
_left: columnDatum.offset + horizontalOffsetAdjustment, |
|
|
|
|
|
|
|
_top: rowDatum.offset + verticalOffsetAdjustment |
|
|
|
|
|
|
|
// _width: columnDatum.size,
|
|
|
|
|
|
|
|
// _height: rowDatum.size
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment); |
|
|
|
|
|
|
|
maxX = Math.max(maxX, columnDatum.offset + horizontalOffsetAdjustment + columnDatum.size); |
|
|
|
|
|
|
|
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); |
|
|
|
|
|
|
|
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); |
|
|
|
|
|
|
|
renderedKeys[key] = [rowIndex, columnIndex, count]; |
|
|
|
|
|
|
|
renderedWidgets[count] = child; |
|
|
|
|
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment); |
|
|
|
|
|
|
|
maxX = Math.max(maxX, columnDatum.offset + horizontalOffsetAdjustment + columnDatum.size); |
|
|
|
|
|
|
|
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); |
|
|
|
|
|
|
|
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); |
|
|
|
|
|
|
|
renderedKeys[key] = [rowIndex, columnIndex, count]; |
|
|
|
|
|
|
|
renderedWidgets[count] = child; |
|
|
|
|
|
|
|
count++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 已存在的, 需要添加的和需要删除的
|
|
|
|
// 已存在的, 需要添加的和需要删除的
|
|
|
|