|
@@ -1,112 +0,0 @@
|
|
|
-Ext.define('saas.override.grid.buffer.BufferedRenderer', {
|
|
|
|
|
- override: 'Ext.grid.plugin.BufferedRenderer',
|
|
|
|
|
-
|
|
|
|
|
- setViewSize: function(viewSize, fromLockingPartner) {
|
|
|
|
|
- var me = this,
|
|
|
|
|
- store = me.store,
|
|
|
|
|
- view = me.view,
|
|
|
|
|
- ownerGrid,
|
|
|
|
|
- rows = view.all,
|
|
|
|
|
- elCount = rows.getCount(),
|
|
|
|
|
- storeCount = store.getCount(),
|
|
|
|
|
- start, end,
|
|
|
|
|
- lockingPartner = me.view.lockingPartner && me.view.lockingPartner.bufferedRenderer,
|
|
|
|
|
- diff = elCount - viewSize,
|
|
|
|
|
- oldTop = 0,
|
|
|
|
|
- maxIndex = Math.max(0, storeCount - 1),
|
|
|
|
|
- // This is which end is closer to being visible therefore must be the first to have rows added
|
|
|
|
|
- // or the opposite end from which rows get removed if shrinking the view.
|
|
|
|
|
- pointyEnd = Ext.Number.sign((me.getFirstVisibleRowIndex() - rows.startIndex) - (rows.endIndex - me.getLastVisibleRowIndex()));
|
|
|
|
|
- // Synchronize view sizes
|
|
|
|
|
- if (lockingPartner && !fromLockingPartner) {
|
|
|
|
|
- lockingPartner.setViewSize(viewSize, true);
|
|
|
|
|
- }
|
|
|
|
|
- diff = elCount - viewSize;
|
|
|
|
|
- if (diff) {
|
|
|
|
|
- // Must be set for getFirstVisibleRowIndex to work
|
|
|
|
|
- me.scrollTop = me.scroller ? me.scroller.getPosition().y : 0;
|
|
|
|
|
- me.viewSize = viewSize;
|
|
|
|
|
- if (store.isBufferedStore) {
|
|
|
|
|
- store.setViewSize(viewSize);
|
|
|
|
|
- }
|
|
|
|
|
- // If a store loads before we have calculated a viewSize, it loads me.defaultViewSize records.
|
|
|
|
|
- // This may be larger or smaller than the final viewSize so the store needs adjusting when the view size is calculated.
|
|
|
|
|
- if (elCount) {
|
|
|
|
|
- // New start index should be current start index unless that's now too close to the end of the store
|
|
|
|
|
- // to yield a full view, in which case work back from the end of the store.
|
|
|
|
|
- // Ensure we don't go negative.
|
|
|
|
|
- start = Math.max(0, Math.min(rows.startIndex, storeCount - viewSize));
|
|
|
|
|
- // New end index works forward from the new start index ensuring we don't walk off the end
|
|
|
|
|
- end = Math.min(start + viewSize - 1, maxIndex);
|
|
|
|
|
- // Only do expensive adding or removal if range is not already correct
|
|
|
|
|
- if (start === rows.startIndex && end === rows.endIndex) {
|
|
|
|
|
- // Needs rows adding to or bottom depending on which end is closest
|
|
|
|
|
- // to being visible (The pointy end)
|
|
|
|
|
- if (diff < 0) {
|
|
|
|
|
- me.handleViewScroll(pointyEnd);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // While changing our visible range, the locking partner must not sync
|
|
|
|
|
- if (lockingPartner) {
|
|
|
|
|
- lockingPartner.disable();
|
|
|
|
|
- }
|
|
|
|
|
- // View must expand
|
|
|
|
|
- if (diff < 0) {
|
|
|
|
|
- // If it's *possible* to add rows...
|
|
|
|
|
- if (storeCount > viewSize && storeCount > elCount) {
|
|
|
|
|
- // Grab the render range with a view to appending and prepending
|
|
|
|
|
- // nodes to the top and bottom as necessary.
|
|
|
|
|
- // Store's getRange API always has been inclusive of endIndex.
|
|
|
|
|
- store.getRange(start, end, {
|
|
|
|
|
- callback: function(newRecords, start, end) {
|
|
|
|
|
- ownerGrid = view.ownerGrid;
|
|
|
|
|
- // Append if necessary
|
|
|
|
|
- if (end > rows.endIndex) {
|
|
|
|
|
- rows.scroll(Ext.Array.slice(newRecords, rows.endIndex + 1, Infinity), 1, 0);
|
|
|
|
|
- }
|
|
|
|
|
- // Prepend if necessary
|
|
|
|
|
- if (start < rows.startIndex) {
|
|
|
|
|
- oldTop = rows.first(true);
|
|
|
|
|
- rows.scroll(Ext.Array.slice(newRecords, 0, rows.startIndex - start), -1, 0);
|
|
|
|
|
- // We just added some rows to the top of the rendered block
|
|
|
|
|
- // We have to bump it up to keep the view stable.
|
|
|
|
|
- me.bodyTop -= oldTop.offsetTop;
|
|
|
|
|
- }
|
|
|
|
|
- me.setBodyTop(me.bodyTop);
|
|
|
|
|
- // The newly added rows must sync the row heights
|
|
|
|
|
- if (lockingPartner && !fromLockingPartner && (ownerGrid.syncRowHeight || ownerGrid.syncRowHeightOnNextLayout)) {
|
|
|
|
|
- lockingPartner.setViewSize(viewSize, true);
|
|
|
|
|
- ownerGrid.syncRowHeights();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- } else // If not possible just refresh
|
|
|
|
|
- {
|
|
|
|
|
- me.refreshView(0);
|
|
|
|
|
- }
|
|
|
|
|
- } else // View size is contracting
|
|
|
|
|
- {
|
|
|
|
|
- // If removing from top, we have to bump the rendered block downwards
|
|
|
|
|
- // by the height of the removed rows.
|
|
|
|
|
- if (pointyEnd === 1) {
|
|
|
|
|
- oldTop = rows.item(rows.startIndex + diff, true).offsetTop;
|
|
|
|
|
- }
|
|
|
|
|
- // Clip the rows off the required end
|
|
|
|
|
- rows.clip(pointyEnd, diff);
|
|
|
|
|
- me.setBodyTop(me.bodyTop + oldTop);
|
|
|
|
|
- }
|
|
|
|
|
- if (lockingPartner) {
|
|
|
|
|
- lockingPartner.enable();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // Update scroll range
|
|
|
|
|
- me.refreshSize();
|
|
|
|
|
- }
|
|
|
|
|
- if(this.grid.xtype=='power-grid'){
|
|
|
|
|
- viewSize = 61
|
|
|
|
|
- }
|
|
|
|
|
- return viewSize;
|
|
|
|
|
- },
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|