New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ag-grid-enterprise/server-side-row-model

Package Overview
Dependencies
Maintainers
3
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ag-grid-enterprise/server-side-row-model - npm Package Compare versions

Comparing version 24.1.0 to 25.0.0

dist/cjs/serverSideRowModel/blocks/blockUtils.d.ts

70

dist/cjs/serverSideRowModel/serverSideRowModel.d.ts

@@ -1,4 +0,14 @@

import { BeanStub, IServerSideDatasource, IServerSideRowModel, RowBounds, RowNode, RowDataTransaction } from "@ag-grid-community/core";
import { BeanStub, Column, ColumnVO, IServerSideDatasource, IServerSideRowModel, IServerSideStore, NumberSequence, RowBounds, RowNode, StoreRefreshAfterParams, RefreshStoreParams, ServerSideStoreState } from "@ag-grid-community/core";
export interface SSRMParams {
sortModel: any;
filterModel: any;
lastAccessedSequence: NumberSequence;
dynamicRowHeight: boolean;
rowGroupCols: ColumnVO[];
valueCols: ColumnVO[];
pivotCols: ColumnVO[];
pivotMode: boolean;
datasource?: IServerSideDatasource;
}
export declare class ServerSideRowModel extends BeanStub implements IServerSideRowModel {
private gridOptionsWrapper;
private columnController;

@@ -10,38 +20,33 @@ private filterManager;

private rowRenderer;
private sortListener;
private nodeManager;
private storeFactory;
private rootNode;
private datasource;
private rowHeight;
private cacheParams;
private rowNodeBlockLoader;
private storeParams;
private pauseStoreUpdateListening;
private logger;
ensureRowHeightsValid(startPixel: number, endPixel: number, startLimitIndex: number, endLimitIndex: number): boolean;
private postConstruct;
ensureRowHeightsValid(): boolean;
start(): void;
private destroyDatasource;
private setBeans;
applyTransaction(rowDataTransaction: RowDataTransaction, route: string[]): void;
private addEventListeners;
setDatasource(datasource: IServerSideDatasource): void;
isLastRowFound(): boolean;
isLastRowIndexKnown(): boolean;
private onColumnEverything;
private onFilterChanged;
private findChangedColumnsInSort;
private onSortChanged;
private onValueChanged;
private onColumnRowGroupChanged;
private onColumnPivotChanged;
private onPivotModeChanged;
private onRowGroupOpened;
private reset;
private createNewRowNodeBlockLoader;
private destroyRowNodeBlockLoader;
private toValueObjects;
private createCacheParams;
private createNodeCache;
private onCacheUpdated;
private destroyRootStore;
refreshAfterSort(newSortModel: any, params: StoreRefreshAfterParams): void;
resetRootStore(): void;
columnsToValueObjects(columns: Column[]): ColumnVO[];
private createStoreParams;
getParams(): SSRMParams;
private dispatchModelUpdated;
private onStoreUpdated;
onRowHeightChanged(): void;
updateRowIndexesAndBounds(): void;
private setDisplayIndexes;
private resetRowTops;
retryLoads(): void;
getRow(index: number): RowNode | null;
expandAll(value: boolean): void;
refreshAfterFilter(newFilterModel: any, params: StoreRefreshAfterParams): void;
getRootStore(): IServerSideStore | undefined;
getRowCount(): number;

@@ -52,3 +57,2 @@ getTopLevelRowCount(): number;

getRowIndexAtPixel(pixel: number): number;
getCurrentPageHeight(): number;
isEmpty(): boolean;

@@ -58,14 +62,8 @@ isRowsToRender(): boolean;

forEachNode(callback: (rowNode: RowNode, index: number) => void): void;
private executeOnCache;
purgeCache(route?: string[]): void;
executeOnStore(route: string[], callback: (cache: IServerSideStore) => void): void;
refreshStore(params?: RefreshStoreParams): void;
getStoreState(): ServerSideStoreState[];
getNodesInRangeForSelection(firstInRange: RowNode, lastInRange: RowNode): RowNode[];
getRowNode(id: string): RowNode | null;
getBlockState(): any;
isRowPresent(rowNode: RowNode): boolean;
private extractSortModel;
private isSortingWithValueColumn;
private isSortingWithSecondaryColumn;
private cacheExists;
private createDetailNode;
isLoading(): boolean;
}

@@ -26,15 +26,11 @@ "use strict";

var core_1 = require("@ag-grid-community/core");
var serverSideCache_1 = require("./serverSideCache");
var serverSideBlock_1 = require("./serverSideBlock");
var ServerSideRowModel = /** @class */ (function (_super) {
__extends(ServerSideRowModel, _super);
function ServerSideRowModel() {
return _super !== null && _super.apply(this, arguments) || this;
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.pauseStoreUpdateListening = false;
return _this;
}
// we don't implement as lazy row heights is not supported in this row model
ServerSideRowModel.prototype.ensureRowHeightsValid = function (startPixel, endPixel, startLimitIndex, endLimitIndex) { return false; };
ServerSideRowModel.prototype.postConstruct = function () {
this.rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber();
this.addEventListeners();
};
ServerSideRowModel.prototype.ensureRowHeightsValid = function () { return false; };
ServerSideRowModel.prototype.start = function () {

@@ -59,16 +55,10 @@ var datasource = this.gridOptionsWrapper.getServerSideDatasource();

};
ServerSideRowModel.prototype.applyTransaction = function (rowDataTransaction, route) {
this.executeOnCache(route, function (cache) {
cache.applyTransaction(rowDataTransaction);
});
};
ServerSideRowModel.prototype.addEventListeners = function () {
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.onColumnRowGroupChanged.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_ROW_GROUP_OPENED, this.onRowGroupOpened.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, this.onPivotModeChanged.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.onColumnEverything.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_VALUE_CHANGED, this.onValueChanged.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_PIVOT_CHANGED, this.onColumnPivotChanged.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_NEW_COLUMNS_LOADED, this.onColumnEverything.bind(this));
this.addManagedListener(this.eventService, core_1.Events.EVENT_STORE_UPDATED, this.onStoreUpdated.bind(this));
var resetListener = this.resetRootStore.bind(this);
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_VALUE_CHANGED, resetListener);
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_PIVOT_CHANGED, resetListener);
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_ROW_GROUP_CHANGED, resetListener);
this.addManagedListener(this.eventService, core_1.Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, resetListener);
};

@@ -78,9 +68,10 @@ ServerSideRowModel.prototype.setDatasource = function (datasource) {

this.datasource = datasource;
this.reset();
this.resetRootStore();
};
ServerSideRowModel.prototype.isLastRowFound = function () {
if (this.cacheExists()) {
return this.rootNode.childrenCache.isMaxRowFound();
ServerSideRowModel.prototype.isLastRowIndexKnown = function () {
var cache = this.getRootStore();
if (!cache) {
return false;
}
return false;
return cache.isLastRowIndexKnown();
};

@@ -96,119 +87,41 @@ ServerSideRowModel.prototype.onColumnEverything = function () {

// every other customer can continue as normal and have it working!!!
// if first time, alwasy reset
if (!this.storeParams) {
this.resetRootStore();
return;
}
// check if anything pertaining to fetching data has changed, and if it has, reset, but if
// it has not, don't reset
var resetRequired;
if (!this.cacheParams) {
resetRequired = true;
}
else {
var rowGroupColumnVos = this.toValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.toValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.toValueObjects(this.columnController.getPivotColumns());
var sortModelDifferent = !core_1._.jsonEquals(this.cacheParams.sortModel, this.sortController.getSortModel());
var rowGroupDifferent = !core_1._.jsonEquals(this.cacheParams.rowGroupCols, rowGroupColumnVos);
var pivotDifferent = !core_1._.jsonEquals(this.cacheParams.pivotCols, pivotColumnVos);
var valuesDifferent = !core_1._.jsonEquals(this.cacheParams.valueCols, valueColumnVos);
resetRequired = sortModelDifferent || rowGroupDifferent || pivotDifferent || valuesDifferent;
}
var rowGroupColumnVos = this.columnsToValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.columnsToValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.columnsToValueObjects(this.columnController.getPivotColumns());
var sortModelDifferent = !core_1._.jsonEquals(this.storeParams.sortModel, this.sortController.getSortModel());
var rowGroupDifferent = !core_1._.jsonEquals(this.storeParams.rowGroupCols, rowGroupColumnVos);
var pivotDifferent = !core_1._.jsonEquals(this.storeParams.pivotCols, pivotColumnVos);
var valuesDifferent = !core_1._.jsonEquals(this.storeParams.valueCols, valueColumnVos);
var resetRequired = sortModelDifferent || rowGroupDifferent || pivotDifferent || valuesDifferent;
if (resetRequired) {
this.reset();
this.resetRootStore();
}
};
ServerSideRowModel.prototype.onFilterChanged = function () {
this.reset();
};
// returns back all the cols that were effected by the sorting. eg if we were sorting by col A,
// and now we are sorting by col B, the list of impacted cols should be A and B. so if a cache
// is impacted by sorting on A or B then it needs to be refreshed. this includes where the cache
// was previously sorted by A and then the A sort now needs to be cleared.
ServerSideRowModel.prototype.findChangedColumnsInSort = function (newSortModel, oldSortModel) {
var allColsInBothSorts = [];
[newSortModel, oldSortModel].forEach(function (sortModel) {
if (sortModel) {
var ids = sortModel.map(function (sm) { return sm.colId; });
allColsInBothSorts = allColsInBothSorts.concat(ids);
}
});
var differentSorts = function (oldSortItem, newSortItem) {
var oldSort = oldSortItem ? oldSortItem.sort : null;
var newSort = newSortItem ? newSortItem.sort : null;
return oldSort !== newSort;
};
var differentIndexes = function (oldSortItem, newSortItem) {
var oldIndex = oldSortModel.indexOf(oldSortItem);
var newIndex = newSortModel.indexOf(newSortItem);
return oldIndex !== newIndex;
};
return allColsInBothSorts.filter(function (colId) {
var oldSortItem = core_1._.find(oldSortModel, function (sm) { return sm.colId === colId; });
var newSortItem = core_1._.find(newSortModel, function (sm) { return sm.colId === colId; });
return differentSorts(oldSortItem, newSortItem) || differentIndexes(oldSortItem, newSortItem);
});
};
ServerSideRowModel.prototype.onSortChanged = function () {
if (!this.cacheExists()) {
ServerSideRowModel.prototype.destroyRootStore = function () {
if (!this.rootNode || !this.rootNode.childStore) {
return;
}
var newSortModel = this.extractSortModel();
var oldSortModel = this.cacheParams.sortModel;
var changedColumnsInSort = this.findChangedColumnsInSort(newSortModel, oldSortModel);
this.cacheParams.sortModel = newSortModel;
var rowGroupColIds = this.columnController.getRowGroupColumns().map(function (col) { return col.getId(); });
var serverSideCache = this.rootNode.childrenCache;
var sortingWithValueCol = this.isSortingWithValueColumn(changedColumnsInSort);
var sortingWithSecondaryCol = this.isSortingWithSecondaryColumn(changedColumnsInSort);
var sortAlwaysResets = this.gridOptionsWrapper.isServerSideSortingAlwaysResets();
if (sortAlwaysResets || sortingWithValueCol || sortingWithSecondaryCol) {
this.reset();
}
else {
serverSideCache.refreshCacheAfterSort(changedColumnsInSort, rowGroupColIds);
}
this.rootNode.childStore = this.destroyBean(this.rootNode.childStore);
this.nodeManager.clear();
};
ServerSideRowModel.prototype.onValueChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onColumnRowGroupChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onColumnPivotChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onPivotModeChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onRowGroupOpened = function (event) {
var _this = this;
var rowNode = event.node;
if (rowNode.expanded) {
if (rowNode.master) {
this.createDetailNode(rowNode);
}
else if (core_1._.missing(rowNode.childrenCache)) {
this.createNodeCache(rowNode);
}
ServerSideRowModel.prototype.refreshAfterSort = function (newSortModel, params) {
if (this.storeParams) {
this.storeParams.sortModel = newSortModel;
}
else if (this.gridOptionsWrapper.isPurgeClosedRowNodes() && core_1._.exists(rowNode.childrenCache)) {
rowNode.childrenCache = this.destroyBean(rowNode.childrenCache);
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
var shouldAnimate = function () {
var rowAnimationEnabled = _this.gridOptionsWrapper.isAnimateRows();
if (rowNode.master) {
return rowAnimationEnabled && rowNode.expanded;
}
return rowAnimationEnabled;
};
this.updateRowIndexesAndBounds();
var modelUpdatedEvent = {
type: core_1.Events.EVENT_MODEL_UPDATED,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
newPage: false,
newData: false,
animate: shouldAnimate(),
keepRenderedRows: true
};
this.eventService.dispatchEvent(modelUpdatedEvent);
rootStore.refreshAfterSort(params);
this.onStoreUpdated();
};
ServerSideRowModel.prototype.reset = function () {
ServerSideRowModel.prototype.resetRootStore = function () {
this.destroyRootStore();
this.rootNode = new core_1.RowNode();

@@ -219,5 +132,4 @@ this.rootNode.group = true;

if (this.datasource) {
this.createNewRowNodeBlockLoader();
this.cacheParams = this.createCacheParams();
this.createNodeCache(this.rootNode);
this.storeParams = this.createStoreParams();
this.rootNode.childStore = this.createBean(this.storeFactory.createStore(this.storeParams, this.rootNode));
this.updateRowIndexesAndBounds();

@@ -235,27 +147,5 @@ }

// to treat the rows as new rows, as it's all new data
var modelUpdatedEvent = {
type: core_1.Events.EVENT_MODEL_UPDATED,
api: this.gridApi,
columnApi: this.columnApi,
animate: false,
keepRenderedRows: false,
newData: false,
newPage: false
};
this.eventService.dispatchEvent(modelUpdatedEvent);
this.dispatchModelUpdated(true);
};
ServerSideRowModel.prototype.createNewRowNodeBlockLoader = function () {
this.destroyRowNodeBlockLoader();
var maxConcurrentRequests = this.gridOptionsWrapper.getMaxConcurrentDatasourceRequests();
var blockLoadDebounceMillis = this.gridOptionsWrapper.getBlockLoadDebounceMillis();
this.rowNodeBlockLoader = new core_1.RowNodeBlockLoader(maxConcurrentRequests, blockLoadDebounceMillis);
this.createBean(this.rowNodeBlockLoader);
};
ServerSideRowModel.prototype.destroyRowNodeBlockLoader = function () {
if (this.rowNodeBlockLoader) {
this.destroyBean(this.rowNodeBlockLoader);
this.rowNodeBlockLoader = undefined;
}
};
ServerSideRowModel.prototype.toValueObjects = function (columns) {
ServerSideRowModel.prototype.columnsToValueObjects = function (columns) {
var _this = this;

@@ -269,26 +159,7 @@ return columns.map(function (col) { return ({

};
ServerSideRowModel.prototype.createCacheParams = function () {
var rowGroupColumnVos = this.toValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.toValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.toValueObjects(this.columnController.getPivotColumns());
ServerSideRowModel.prototype.createStoreParams = function () {
var rowGroupColumnVos = this.columnsToValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.columnsToValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.columnsToValueObjects(this.columnController.getPivotColumns());
var dynamicRowHeight = this.gridOptionsWrapper.isDynamicRowHeight();
var maxBlocksInCache = this.gridOptionsWrapper.getMaxBlocksInCache();
if (dynamicRowHeight && maxBlocksInCache >= 0) {
console.warn('ag-Grid: Server Side Row Model does not support Dynamic Row Height and Cache Purging. ' +
'Either a) remove getRowHeight() callback or b) remove maxBlocksInCache property. Purging has been disabled.');
maxBlocksInCache = undefined;
}
if (maxBlocksInCache >= 0 && this.columnController.isAutoRowHeightActive()) {
console.warn('ag-Grid: Server Side Row Model does not support Auto Row Height and Cache Purging. ' +
'Either a) remove colDef.autoHeight or b) remove maxBlocksInCache property. Purging has been disabled.');
maxBlocksInCache = undefined;
}
var userProvidedBlockSize = this.gridOptionsWrapper.getCacheBlockSize();
var blockSize;
if (typeof userProvidedBlockSize == 'number' && userProvidedBlockSize > 0) {
blockSize = userProvidedBlockSize;
}
else {
blockSize = serverSideBlock_1.ServerSideBlock.DefaultBlockSize;
}
var params = {

@@ -302,11 +173,6 @@ // the columns the user has grouped and aggregated by

filterModel: this.filterManager.getFilterModel(),
sortModel: this.extractSortModel(),
rowNodeBlockLoader: this.rowNodeBlockLoader,
sortModel: this.sortListener.extractSortModel(),
datasource: this.datasource,
lastAccessedSequence: new core_1.NumberSequence(),
overflowSize: 1,
initialRowCount: 1,
maxBlocksInCache: maxBlocksInCache,
blockSize: blockSize,
rowHeight: this.rowHeight,
// blockSize: blockSize == null ? 100 : blockSize,
dynamicRowHeight: dynamicRowHeight

@@ -316,10 +182,7 @@ };

};
ServerSideRowModel.prototype.createNodeCache = function (rowNode) {
var cache = new serverSideCache_1.ServerSideCache(this.cacheParams, rowNode);
this.getContext().createBean(cache);
cache.addEventListener(core_1.RowNodeCache.EVENT_CACHE_UPDATED, this.onCacheUpdated.bind(this));
rowNode.childrenCache = cache;
ServerSideRowModel.prototype.getParams = function () {
return this.storeParams;
};
ServerSideRowModel.prototype.onCacheUpdated = function () {
this.updateRowIndexesAndBounds();
ServerSideRowModel.prototype.dispatchModelUpdated = function (reset) {
if (reset === void 0) { reset = false; }
var modelUpdatedEvent = {

@@ -329,4 +192,4 @@ type: core_1.Events.EVENT_MODEL_UPDATED,

columnApi: this.columnApi,
animate: this.gridOptionsWrapper.isAnimateRows(),
keepRenderedRows: true,
animate: !reset,
keepRenderedRows: !reset,
newPage: false,

@@ -337,85 +200,105 @@ newData: false

};
ServerSideRowModel.prototype.onStoreUpdated = function () {
// sometimes if doing a batch update, we do the batch first,
// then call onStoreUpdated manually. eg expandAll() method.
if (this.pauseStoreUpdateListening) {
return;
}
this.updateRowIndexesAndBounds();
this.dispatchModelUpdated();
};
ServerSideRowModel.prototype.onRowHeightChanged = function () {
this.updateRowIndexesAndBounds();
var modelUpdatedEvent = {
type: core_1.Events.EVENT_MODEL_UPDATED,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
newPage: false,
newData: false,
animate: true,
keepRenderedRows: true
};
this.eventService.dispatchEvent(modelUpdatedEvent);
this.dispatchModelUpdated();
};
ServerSideRowModel.prototype.updateRowIndexesAndBounds = function () {
if (this.cacheExists()) {
// NOTE: should not be casting here, the RowModel should use IServerSideRowModel interface?
var serverSideCache = this.rootNode.childrenCache;
this.resetRowTops(serverSideCache);
this.setDisplayIndexes(serverSideCache);
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.setDisplayIndexes(new core_1.NumberSequence(), { value: 0 });
};
ServerSideRowModel.prototype.setDisplayIndexes = function (cache) {
var numberSequence = new core_1.NumberSequence();
var nextRowTop = { value: 0 };
cache.setDisplayIndexes(numberSequence, nextRowTop);
ServerSideRowModel.prototype.retryLoads = function () {
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.retryLoads();
this.onStoreUpdated();
};
// resetting row tops is needed for animation, as part of the operation is saving the old location,
// which is needed for rows that are transitioning in
ServerSideRowModel.prototype.resetRowTops = function (cache) {
var numberSequence = new core_1.NumberSequence();
cache.forEachNodeDeep(function (rowNode) { return rowNode.clearRowTop(); }, numberSequence);
};
ServerSideRowModel.prototype.getRow = function (index) {
if (this.cacheExists()) {
return this.rootNode.childrenCache.getRow(index);
var rootStore = this.getRootStore();
if (!rootStore) {
return null;
}
return null;
return rootStore.getRowUsingDisplayIndex(index);
};
ServerSideRowModel.prototype.expandAll = function (value) {
// if we don't pause store updating, we are needlessly
// recalculating row-indexes etc, and also getting rendering
// engine to re-render (listens on ModelUpdated event)
this.pauseStoreUpdateListening = true;
this.forEachNode(function (node) {
if (node.group) {
node.setExpanded(value);
}
});
this.pauseStoreUpdateListening = false;
this.onStoreUpdated();
};
ServerSideRowModel.prototype.refreshAfterFilter = function (newFilterModel, params) {
if (this.storeParams) {
this.storeParams.filterModel = newFilterModel;
}
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.refreshAfterFilter(params);
this.onStoreUpdated();
};
ServerSideRowModel.prototype.getRootStore = function () {
if (this.rootNode && this.rootNode.childStore) {
return this.rootNode.childStore;
}
};
ServerSideRowModel.prototype.getRowCount = function () {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
return 1;
}
var serverSideCache = this.rootNode.childrenCache;
var res = serverSideCache.getDisplayIndexEnd();
return res;
return rootStore.getDisplayIndexEnd();
};
ServerSideRowModel.prototype.getTopLevelRowCount = function () {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
return 1;
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getVirtualRowCount();
return rootStore.getRowCount();
};
ServerSideRowModel.prototype.getTopLevelRowDisplayedIndex = function (topLevelIndex) {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
return topLevelIndex;
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getTopLevelRowDisplayedIndex(topLevelIndex);
return rootStore.getTopLevelRowDisplayedIndex(topLevelIndex);
};
ServerSideRowModel.prototype.getRowBounds = function (index) {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
var rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber();
return {
rowTop: 0,
rowHeight: this.rowHeight
rowHeight: rowHeight
};
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getRowBounds(index);
return rootStore.getRowBounds(index);
};
ServerSideRowModel.prototype.getRowIndexAtPixel = function (pixel) {
if (pixel === 0) {
var rootStore = this.getRootStore();
if (pixel <= 0 || !rootStore) {
return 0;
}
if (!this.cacheExists()) {
return 0;
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getRowIndexAtPixel(pixel);
return rootStore.getRowIndexAtPixel(pixel);
};
ServerSideRowModel.prototype.getCurrentPageHeight = function () {
return this.rowHeight * this.getRowCount();
};
ServerSideRowModel.prototype.isEmpty = function () {

@@ -425,3 +308,3 @@ return false;

ServerSideRowModel.prototype.isRowsToRender = function () {
return this.cacheExists() && this.getRowCount() > 0;
return this.getRootStore() != null && this.getRowCount() > 0;
};

@@ -432,20 +315,31 @@ ServerSideRowModel.prototype.getType = function () {

ServerSideRowModel.prototype.forEachNode = function (callback) {
if (this.cacheExists()) {
this.rootNode.childrenCache.forEachNodeDeep(callback);
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.forEachNodeDeep(callback);
};
ServerSideRowModel.prototype.executeOnCache = function (route, callback) {
if (!this.cacheExists()) {
ServerSideRowModel.prototype.executeOnStore = function (route, callback) {
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
var topLevelCache = this.rootNode.childrenCache;
var cacheToPurge = topLevelCache.getChildCache(route);
if (cacheToPurge) {
callback(cacheToPurge);
var storeToExecuteOn = rootStore.getChildStore(route);
if (storeToExecuteOn) {
callback(storeToExecuteOn);
}
};
ServerSideRowModel.prototype.purgeCache = function (route) {
if (route === void 0) { route = []; }
this.executeOnCache(route, function (cache) { return cache.purgeCache(); });
ServerSideRowModel.prototype.refreshStore = function (params) {
if (params === void 0) { params = {}; }
var route = params.route ? params.route : [];
this.executeOnStore(route, function (store) { return store.refreshStore(params.purge == true); });
};
ServerSideRowModel.prototype.getStoreState = function () {
var res = [];
var rootStore = this.getRootStore();
if (rootStore) {
rootStore.addStoreStates(res);
}
return res;
};
ServerSideRowModel.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {

@@ -455,3 +349,3 @@ if (core_1._.exists(lastInRange) && firstInRange.parent !== lastInRange.parent) {

}
return firstInRange.parent.childrenCache.getRowNodesInRange(lastInRange, firstInRange);
return firstInRange.parent.childStore.getRowNodesInRange(lastInRange, firstInRange);
};

@@ -470,9 +364,2 @@ ServerSideRowModel.prototype.getRowNode = function (id) {

};
ServerSideRowModel.prototype.getBlockState = function () {
if (this.rowNodeBlockLoader) {
return this.rowNodeBlockLoader.getBlockState();
}
return null;
};
// always returns true - this is used by the
ServerSideRowModel.prototype.isRowPresent = function (rowNode) {

@@ -482,104 +369,3 @@ var foundRowNode = this.getRowNode(rowNode.id);

};
ServerSideRowModel.prototype.extractSortModel = function () {
var sortModel = this.sortController.getSortModel();
// when using tree data we just return the sort model with the 'ag-Grid-AutoColumn' as is, i.e not broken out
// into it's constitute group columns as they are not defined up front and can vary per node.
if (this.gridOptionsWrapper.isTreeData()) {
return sortModel;
}
var rowGroupCols = this.toValueObjects(this.columnController.getRowGroupColumns());
// find index of auto group column in sort model
var autoGroupIndex = -1;
for (var i = 0; i < sortModel.length; ++i) {
if (sortModel[i].colId === core_1.Constants.GROUP_AUTO_COLUMN_ID) {
autoGroupIndex = i;
break;
}
}
// replace auto column with individual group columns
if (autoGroupIndex > -1) {
var individualGroupCols = rowGroupCols.map(function (group) {
return {
colId: group.id,
sort: sortModel[autoGroupIndex].sort
};
});
// remove auto group column
sortModel.splice(autoGroupIndex, 1);
var _loop_1 = function (i) {
var individualGroupCol = individualGroupCols[i];
// don't add individual group column if non group column already exists as it gets precedence
var sameNonGroupColumnExists = sortModel.some(function (sm) { return sm.colId === individualGroupCol.colId; });
if (sameNonGroupColumnExists) {
return "continue";
}
sortModel.splice(autoGroupIndex++, 0, individualGroupCol);
};
// insert individual group columns
for (var i = 0; i < individualGroupCols.length; i++) {
_loop_1(i);
}
}
// strip out multi-column prefix on colId's
if (this.gridOptionsWrapper.isGroupMultiAutoColumn()) {
var multiColumnPrefix = core_1.Constants.GROUP_AUTO_COLUMN_ID + "-";
for (var i = 0; i < sortModel.length; ++i) {
if (sortModel[i].colId.indexOf(multiColumnPrefix) > -1) {
sortModel[i].colId = sortModel[i].colId.substr(multiColumnPrefix.length);
}
}
}
return sortModel;
};
ServerSideRowModel.prototype.isSortingWithValueColumn = function (changedColumnsInSort) {
var valueColIds = this.columnController.getValueColumns().map(function (col) { return col.getColId(); });
for (var i = 0; i < changedColumnsInSort.length; i++) {
if (valueColIds.indexOf(changedColumnsInSort[i]) > -1) {
return true;
}
}
return false;
};
ServerSideRowModel.prototype.isSortingWithSecondaryColumn = function (changedColumnsInSort) {
if (!this.columnController.getSecondaryColumns()) {
return false;
}
var secondaryColIds = this.columnController.getSecondaryColumns().map(function (col) { return col.getColId(); });
for (var i = 0; i < changedColumnsInSort.length; i++) {
if (secondaryColIds.indexOf(changedColumnsInSort[i]) > -1) {
return true;
}
}
return false;
};
ServerSideRowModel.prototype.cacheExists = function () {
return core_1._.exists(this.rootNode) && core_1._.exists(this.rootNode.childrenCache);
};
ServerSideRowModel.prototype.createDetailNode = function (masterNode) {
if (core_1._.exists(masterNode.detailNode)) {
return masterNode.detailNode;
}
var detailNode = new core_1.RowNode();
this.getContext().createBean(detailNode);
detailNode.detail = true;
detailNode.selectable = false;
detailNode.parent = masterNode;
if (core_1._.exists(masterNode.id)) {
detailNode.id = 'detail_' + masterNode.id;
}
detailNode.data = masterNode.data;
detailNode.level = masterNode.level + 1;
var defaultDetailRowHeight = 200;
var rowHeight = this.gridOptionsWrapper.getRowHeightForNode(detailNode).height;
detailNode.rowHeight = rowHeight ? rowHeight : defaultDetailRowHeight;
masterNode.detailNode = detailNode;
return detailNode;
};
ServerSideRowModel.prototype.isLoading = function () {
return this.rowNodeBlockLoader ? this.rowNodeBlockLoader.isLoading() : false;
};
__decorate([
core_1.Autowired('gridOptionsWrapper')
], ServerSideRowModel.prototype, "gridOptionsWrapper", void 0);
__decorate([
core_1.Autowired('columnController')

@@ -603,5 +389,11 @@ ], ServerSideRowModel.prototype, "columnController", void 0);

__decorate([
core_1.PostConstruct
], ServerSideRowModel.prototype, "postConstruct", null);
core_1.Autowired('ssrmSortService')
], ServerSideRowModel.prototype, "sortListener", void 0);
__decorate([
core_1.Autowired('ssrmNodeManager')
], ServerSideRowModel.prototype, "nodeManager", void 0);
__decorate([
core_1.Autowired('ssrmStoreFactory')
], ServerSideRowModel.prototype, "storeFactory", void 0);
__decorate([
core_1.PreDestroy

@@ -613,4 +405,7 @@ ], ServerSideRowModel.prototype, "destroyDatasource", null);

__decorate([
core_1.PostConstruct
], ServerSideRowModel.prototype, "addEventListeners", null);
__decorate([
core_1.PreDestroy
], ServerSideRowModel.prototype, "destroyRowNodeBlockLoader", null);
], ServerSideRowModel.prototype, "destroyRootStore", null);
ServerSideRowModel = __decorate([

@@ -617,0 +412,0 @@ core_1.Bean('rowModel')

@@ -6,5 +6,16 @@ "use strict";

var serverSideRowModel_1 = require("./serverSideRowModel/serverSideRowModel");
var storeUtils_1 = require("./serverSideRowModel/stores/storeUtils");
var blockUtils_1 = require("./serverSideRowModel/blocks/blockUtils");
var nodeManager_1 = require("./serverSideRowModel/nodeManager");
var transactionManager_1 = require("./serverSideRowModel/transactionManager");
var expandListener_1 = require("./serverSideRowModel/listeners/expandListener");
var sortListener_1 = require("./serverSideRowModel/listeners/sortListener");
var filterListener_1 = require("./serverSideRowModel/listeners/filterListener");
var storeFactory_1 = require("./serverSideRowModel/stores/storeFactory");
var listenerUtils_1 = require("./serverSideRowModel/listeners/listenerUtils");
exports.ServerSideRowModelModule = {
moduleName: core_1.ModuleNames.ServerSideRowModelModule,
rowModels: { 'serverSide': serverSideRowModel_1.ServerSideRowModel },
rowModels: { serverSide: serverSideRowModel_1.ServerSideRowModel },
beans: [expandListener_1.ExpandListener, sortListener_1.SortListener, storeUtils_1.StoreUtils, blockUtils_1.BlockUtils, nodeManager_1.NodeManager, transactionManager_1.TransactionManager,
filterListener_1.FilterListener, storeFactory_1.StoreFactory, listenerUtils_1.ListenerUtils],
dependantModules: [

@@ -11,0 +22,0 @@ core_2.EnterpriseCoreModule

@@ -1,4 +0,14 @@

import { BeanStub, IServerSideDatasource, IServerSideRowModel, RowBounds, RowNode, RowDataTransaction } from "@ag-grid-community/core";
import { BeanStub, Column, ColumnVO, IServerSideDatasource, IServerSideRowModel, IServerSideStore, NumberSequence, RowBounds, RowNode, StoreRefreshAfterParams, RefreshStoreParams, ServerSideStoreState } from "@ag-grid-community/core";
export interface SSRMParams {
sortModel: any;
filterModel: any;
lastAccessedSequence: NumberSequence;
dynamicRowHeight: boolean;
rowGroupCols: ColumnVO[];
valueCols: ColumnVO[];
pivotCols: ColumnVO[];
pivotMode: boolean;
datasource?: IServerSideDatasource;
}
export declare class ServerSideRowModel extends BeanStub implements IServerSideRowModel {
private gridOptionsWrapper;
private columnController;

@@ -10,38 +20,33 @@ private filterManager;

private rowRenderer;
private sortListener;
private nodeManager;
private storeFactory;
private rootNode;
private datasource;
private rowHeight;
private cacheParams;
private rowNodeBlockLoader;
private storeParams;
private pauseStoreUpdateListening;
private logger;
ensureRowHeightsValid(startPixel: number, endPixel: number, startLimitIndex: number, endLimitIndex: number): boolean;
private postConstruct;
ensureRowHeightsValid(): boolean;
start(): void;
private destroyDatasource;
private setBeans;
applyTransaction(rowDataTransaction: RowDataTransaction, route: string[]): void;
private addEventListeners;
setDatasource(datasource: IServerSideDatasource): void;
isLastRowFound(): boolean;
isLastRowIndexKnown(): boolean;
private onColumnEverything;
private onFilterChanged;
private findChangedColumnsInSort;
private onSortChanged;
private onValueChanged;
private onColumnRowGroupChanged;
private onColumnPivotChanged;
private onPivotModeChanged;
private onRowGroupOpened;
private reset;
private createNewRowNodeBlockLoader;
private destroyRowNodeBlockLoader;
private toValueObjects;
private createCacheParams;
private createNodeCache;
private onCacheUpdated;
private destroyRootStore;
refreshAfterSort(newSortModel: any, params: StoreRefreshAfterParams): void;
resetRootStore(): void;
columnsToValueObjects(columns: Column[]): ColumnVO[];
private createStoreParams;
getParams(): SSRMParams;
private dispatchModelUpdated;
private onStoreUpdated;
onRowHeightChanged(): void;
updateRowIndexesAndBounds(): void;
private setDisplayIndexes;
private resetRowTops;
retryLoads(): void;
getRow(index: number): RowNode | null;
expandAll(value: boolean): void;
refreshAfterFilter(newFilterModel: any, params: StoreRefreshAfterParams): void;
getRootStore(): IServerSideStore | undefined;
getRowCount(): number;

@@ -52,3 +57,2 @@ getTopLevelRowCount(): number;

getRowIndexAtPixel(pixel: number): number;
getCurrentPageHeight(): number;
isEmpty(): boolean;

@@ -58,14 +62,8 @@ isRowsToRender(): boolean;

forEachNode(callback: (rowNode: RowNode, index: number) => void): void;
private executeOnCache;
purgeCache(route?: string[]): void;
executeOnStore(route: string[], callback: (cache: IServerSideStore) => void): void;
refreshStore(params?: RefreshStoreParams): void;
getStoreState(): ServerSideStoreState[];
getNodesInRangeForSelection(firstInRange: RowNode, lastInRange: RowNode): RowNode[];
getRowNode(id: string): RowNode | null;
getBlockState(): any;
isRowPresent(rowNode: RowNode): boolean;
private extractSortModel;
private isSortingWithValueColumn;
private isSortingWithSecondaryColumn;
private cacheExists;
private createDetailNode;
isLoading(): boolean;
}

@@ -23,16 +23,12 @@ var __extends = (this && this.__extends) || (function () {

};
import { _, Autowired, Bean, BeanStub, Constants, Events, NumberSequence, PostConstruct, PreDestroy, Qualifier, RowNode, RowNodeBlockLoader, RowNodeCache } from "@ag-grid-community/core";
import { ServerSideCache } from "./serverSideCache";
import { ServerSideBlock } from "./serverSideBlock";
import { _, Autowired, Bean, BeanStub, Constants, Events, NumberSequence, PostConstruct, PreDestroy, Qualifier, RowNode } from "@ag-grid-community/core";
var ServerSideRowModel = /** @class */ (function (_super) {
__extends(ServerSideRowModel, _super);
function ServerSideRowModel() {
return _super !== null && _super.apply(this, arguments) || this;
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.pauseStoreUpdateListening = false;
return _this;
}
// we don't implement as lazy row heights is not supported in this row model
ServerSideRowModel.prototype.ensureRowHeightsValid = function (startPixel, endPixel, startLimitIndex, endLimitIndex) { return false; };
ServerSideRowModel.prototype.postConstruct = function () {
this.rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber();
this.addEventListeners();
};
ServerSideRowModel.prototype.ensureRowHeightsValid = function () { return false; };
ServerSideRowModel.prototype.start = function () {

@@ -57,16 +53,10 @@ var datasource = this.gridOptionsWrapper.getServerSideDatasource();

};
ServerSideRowModel.prototype.applyTransaction = function (rowDataTransaction, route) {
this.executeOnCache(route, function (cache) {
cache.applyTransaction(rowDataTransaction);
});
};
ServerSideRowModel.prototype.addEventListeners = function () {
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.onColumnRowGroupChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_ROW_GROUP_OPENED, this.onRowGroupOpened.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, this.onPivotModeChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.onColumnEverything.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VALUE_CHANGED, this.onValueChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_CHANGED, this.onColumnPivotChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_NEW_COLUMNS_LOADED, this.onColumnEverything.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_STORE_UPDATED, this.onStoreUpdated.bind(this));
var resetListener = this.resetRootStore.bind(this);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VALUE_CHANGED, resetListener);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_CHANGED, resetListener);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, resetListener);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, resetListener);
};

@@ -76,9 +66,10 @@ ServerSideRowModel.prototype.setDatasource = function (datasource) {

this.datasource = datasource;
this.reset();
this.resetRootStore();
};
ServerSideRowModel.prototype.isLastRowFound = function () {
if (this.cacheExists()) {
return this.rootNode.childrenCache.isMaxRowFound();
ServerSideRowModel.prototype.isLastRowIndexKnown = function () {
var cache = this.getRootStore();
if (!cache) {
return false;
}
return false;
return cache.isLastRowIndexKnown();
};

@@ -94,119 +85,41 @@ ServerSideRowModel.prototype.onColumnEverything = function () {

// every other customer can continue as normal and have it working!!!
// if first time, alwasy reset
if (!this.storeParams) {
this.resetRootStore();
return;
}
// check if anything pertaining to fetching data has changed, and if it has, reset, but if
// it has not, don't reset
var resetRequired;
if (!this.cacheParams) {
resetRequired = true;
}
else {
var rowGroupColumnVos = this.toValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.toValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.toValueObjects(this.columnController.getPivotColumns());
var sortModelDifferent = !_.jsonEquals(this.cacheParams.sortModel, this.sortController.getSortModel());
var rowGroupDifferent = !_.jsonEquals(this.cacheParams.rowGroupCols, rowGroupColumnVos);
var pivotDifferent = !_.jsonEquals(this.cacheParams.pivotCols, pivotColumnVos);
var valuesDifferent = !_.jsonEquals(this.cacheParams.valueCols, valueColumnVos);
resetRequired = sortModelDifferent || rowGroupDifferent || pivotDifferent || valuesDifferent;
}
var rowGroupColumnVos = this.columnsToValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.columnsToValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.columnsToValueObjects(this.columnController.getPivotColumns());
var sortModelDifferent = !_.jsonEquals(this.storeParams.sortModel, this.sortController.getSortModel());
var rowGroupDifferent = !_.jsonEquals(this.storeParams.rowGroupCols, rowGroupColumnVos);
var pivotDifferent = !_.jsonEquals(this.storeParams.pivotCols, pivotColumnVos);
var valuesDifferent = !_.jsonEquals(this.storeParams.valueCols, valueColumnVos);
var resetRequired = sortModelDifferent || rowGroupDifferent || pivotDifferent || valuesDifferent;
if (resetRequired) {
this.reset();
this.resetRootStore();
}
};
ServerSideRowModel.prototype.onFilterChanged = function () {
this.reset();
};
// returns back all the cols that were effected by the sorting. eg if we were sorting by col A,
// and now we are sorting by col B, the list of impacted cols should be A and B. so if a cache
// is impacted by sorting on A or B then it needs to be refreshed. this includes where the cache
// was previously sorted by A and then the A sort now needs to be cleared.
ServerSideRowModel.prototype.findChangedColumnsInSort = function (newSortModel, oldSortModel) {
var allColsInBothSorts = [];
[newSortModel, oldSortModel].forEach(function (sortModel) {
if (sortModel) {
var ids = sortModel.map(function (sm) { return sm.colId; });
allColsInBothSorts = allColsInBothSorts.concat(ids);
}
});
var differentSorts = function (oldSortItem, newSortItem) {
var oldSort = oldSortItem ? oldSortItem.sort : null;
var newSort = newSortItem ? newSortItem.sort : null;
return oldSort !== newSort;
};
var differentIndexes = function (oldSortItem, newSortItem) {
var oldIndex = oldSortModel.indexOf(oldSortItem);
var newIndex = newSortModel.indexOf(newSortItem);
return oldIndex !== newIndex;
};
return allColsInBothSorts.filter(function (colId) {
var oldSortItem = _.find(oldSortModel, function (sm) { return sm.colId === colId; });
var newSortItem = _.find(newSortModel, function (sm) { return sm.colId === colId; });
return differentSorts(oldSortItem, newSortItem) || differentIndexes(oldSortItem, newSortItem);
});
};
ServerSideRowModel.prototype.onSortChanged = function () {
if (!this.cacheExists()) {
ServerSideRowModel.prototype.destroyRootStore = function () {
if (!this.rootNode || !this.rootNode.childStore) {
return;
}
var newSortModel = this.extractSortModel();
var oldSortModel = this.cacheParams.sortModel;
var changedColumnsInSort = this.findChangedColumnsInSort(newSortModel, oldSortModel);
this.cacheParams.sortModel = newSortModel;
var rowGroupColIds = this.columnController.getRowGroupColumns().map(function (col) { return col.getId(); });
var serverSideCache = this.rootNode.childrenCache;
var sortingWithValueCol = this.isSortingWithValueColumn(changedColumnsInSort);
var sortingWithSecondaryCol = this.isSortingWithSecondaryColumn(changedColumnsInSort);
var sortAlwaysResets = this.gridOptionsWrapper.isServerSideSortingAlwaysResets();
if (sortAlwaysResets || sortingWithValueCol || sortingWithSecondaryCol) {
this.reset();
}
else {
serverSideCache.refreshCacheAfterSort(changedColumnsInSort, rowGroupColIds);
}
this.rootNode.childStore = this.destroyBean(this.rootNode.childStore);
this.nodeManager.clear();
};
ServerSideRowModel.prototype.onValueChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onColumnRowGroupChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onColumnPivotChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onPivotModeChanged = function () {
this.reset();
};
ServerSideRowModel.prototype.onRowGroupOpened = function (event) {
var _this = this;
var rowNode = event.node;
if (rowNode.expanded) {
if (rowNode.master) {
this.createDetailNode(rowNode);
}
else if (_.missing(rowNode.childrenCache)) {
this.createNodeCache(rowNode);
}
ServerSideRowModel.prototype.refreshAfterSort = function (newSortModel, params) {
if (this.storeParams) {
this.storeParams.sortModel = newSortModel;
}
else if (this.gridOptionsWrapper.isPurgeClosedRowNodes() && _.exists(rowNode.childrenCache)) {
rowNode.childrenCache = this.destroyBean(rowNode.childrenCache);
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
var shouldAnimate = function () {
var rowAnimationEnabled = _this.gridOptionsWrapper.isAnimateRows();
if (rowNode.master) {
return rowAnimationEnabled && rowNode.expanded;
}
return rowAnimationEnabled;
};
this.updateRowIndexesAndBounds();
var modelUpdatedEvent = {
type: Events.EVENT_MODEL_UPDATED,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
newPage: false,
newData: false,
animate: shouldAnimate(),
keepRenderedRows: true
};
this.eventService.dispatchEvent(modelUpdatedEvent);
rootStore.refreshAfterSort(params);
this.onStoreUpdated();
};
ServerSideRowModel.prototype.reset = function () {
ServerSideRowModel.prototype.resetRootStore = function () {
this.destroyRootStore();
this.rootNode = new RowNode();

@@ -217,5 +130,4 @@ this.rootNode.group = true;

if (this.datasource) {
this.createNewRowNodeBlockLoader();
this.cacheParams = this.createCacheParams();
this.createNodeCache(this.rootNode);
this.storeParams = this.createStoreParams();
this.rootNode.childStore = this.createBean(this.storeFactory.createStore(this.storeParams, this.rootNode));
this.updateRowIndexesAndBounds();

@@ -233,27 +145,5 @@ }

// to treat the rows as new rows, as it's all new data
var modelUpdatedEvent = {
type: Events.EVENT_MODEL_UPDATED,
api: this.gridApi,
columnApi: this.columnApi,
animate: false,
keepRenderedRows: false,
newData: false,
newPage: false
};
this.eventService.dispatchEvent(modelUpdatedEvent);
this.dispatchModelUpdated(true);
};
ServerSideRowModel.prototype.createNewRowNodeBlockLoader = function () {
this.destroyRowNodeBlockLoader();
var maxConcurrentRequests = this.gridOptionsWrapper.getMaxConcurrentDatasourceRequests();
var blockLoadDebounceMillis = this.gridOptionsWrapper.getBlockLoadDebounceMillis();
this.rowNodeBlockLoader = new RowNodeBlockLoader(maxConcurrentRequests, blockLoadDebounceMillis);
this.createBean(this.rowNodeBlockLoader);
};
ServerSideRowModel.prototype.destroyRowNodeBlockLoader = function () {
if (this.rowNodeBlockLoader) {
this.destroyBean(this.rowNodeBlockLoader);
this.rowNodeBlockLoader = undefined;
}
};
ServerSideRowModel.prototype.toValueObjects = function (columns) {
ServerSideRowModel.prototype.columnsToValueObjects = function (columns) {
var _this = this;

@@ -267,26 +157,7 @@ return columns.map(function (col) { return ({

};
ServerSideRowModel.prototype.createCacheParams = function () {
var rowGroupColumnVos = this.toValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.toValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.toValueObjects(this.columnController.getPivotColumns());
ServerSideRowModel.prototype.createStoreParams = function () {
var rowGroupColumnVos = this.columnsToValueObjects(this.columnController.getRowGroupColumns());
var valueColumnVos = this.columnsToValueObjects(this.columnController.getValueColumns());
var pivotColumnVos = this.columnsToValueObjects(this.columnController.getPivotColumns());
var dynamicRowHeight = this.gridOptionsWrapper.isDynamicRowHeight();
var maxBlocksInCache = this.gridOptionsWrapper.getMaxBlocksInCache();
if (dynamicRowHeight && maxBlocksInCache >= 0) {
console.warn('ag-Grid: Server Side Row Model does not support Dynamic Row Height and Cache Purging. ' +
'Either a) remove getRowHeight() callback or b) remove maxBlocksInCache property. Purging has been disabled.');
maxBlocksInCache = undefined;
}
if (maxBlocksInCache >= 0 && this.columnController.isAutoRowHeightActive()) {
console.warn('ag-Grid: Server Side Row Model does not support Auto Row Height and Cache Purging. ' +
'Either a) remove colDef.autoHeight or b) remove maxBlocksInCache property. Purging has been disabled.');
maxBlocksInCache = undefined;
}
var userProvidedBlockSize = this.gridOptionsWrapper.getCacheBlockSize();
var blockSize;
if (typeof userProvidedBlockSize == 'number' && userProvidedBlockSize > 0) {
blockSize = userProvidedBlockSize;
}
else {
blockSize = ServerSideBlock.DefaultBlockSize;
}
var params = {

@@ -300,11 +171,6 @@ // the columns the user has grouped and aggregated by

filterModel: this.filterManager.getFilterModel(),
sortModel: this.extractSortModel(),
rowNodeBlockLoader: this.rowNodeBlockLoader,
sortModel: this.sortListener.extractSortModel(),
datasource: this.datasource,
lastAccessedSequence: new NumberSequence(),
overflowSize: 1,
initialRowCount: 1,
maxBlocksInCache: maxBlocksInCache,
blockSize: blockSize,
rowHeight: this.rowHeight,
// blockSize: blockSize == null ? 100 : blockSize,
dynamicRowHeight: dynamicRowHeight

@@ -314,10 +180,7 @@ };

};
ServerSideRowModel.prototype.createNodeCache = function (rowNode) {
var cache = new ServerSideCache(this.cacheParams, rowNode);
this.getContext().createBean(cache);
cache.addEventListener(RowNodeCache.EVENT_CACHE_UPDATED, this.onCacheUpdated.bind(this));
rowNode.childrenCache = cache;
ServerSideRowModel.prototype.getParams = function () {
return this.storeParams;
};
ServerSideRowModel.prototype.onCacheUpdated = function () {
this.updateRowIndexesAndBounds();
ServerSideRowModel.prototype.dispatchModelUpdated = function (reset) {
if (reset === void 0) { reset = false; }
var modelUpdatedEvent = {

@@ -327,4 +190,4 @@ type: Events.EVENT_MODEL_UPDATED,

columnApi: this.columnApi,
animate: this.gridOptionsWrapper.isAnimateRows(),
keepRenderedRows: true,
animate: !reset,
keepRenderedRows: !reset,
newPage: false,

@@ -335,85 +198,105 @@ newData: false

};
ServerSideRowModel.prototype.onStoreUpdated = function () {
// sometimes if doing a batch update, we do the batch first,
// then call onStoreUpdated manually. eg expandAll() method.
if (this.pauseStoreUpdateListening) {
return;
}
this.updateRowIndexesAndBounds();
this.dispatchModelUpdated();
};
ServerSideRowModel.prototype.onRowHeightChanged = function () {
this.updateRowIndexesAndBounds();
var modelUpdatedEvent = {
type: Events.EVENT_MODEL_UPDATED,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
newPage: false,
newData: false,
animate: true,
keepRenderedRows: true
};
this.eventService.dispatchEvent(modelUpdatedEvent);
this.dispatchModelUpdated();
};
ServerSideRowModel.prototype.updateRowIndexesAndBounds = function () {
if (this.cacheExists()) {
// NOTE: should not be casting here, the RowModel should use IServerSideRowModel interface?
var serverSideCache = this.rootNode.childrenCache;
this.resetRowTops(serverSideCache);
this.setDisplayIndexes(serverSideCache);
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.setDisplayIndexes(new NumberSequence(), { value: 0 });
};
ServerSideRowModel.prototype.setDisplayIndexes = function (cache) {
var numberSequence = new NumberSequence();
var nextRowTop = { value: 0 };
cache.setDisplayIndexes(numberSequence, nextRowTop);
ServerSideRowModel.prototype.retryLoads = function () {
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.retryLoads();
this.onStoreUpdated();
};
// resetting row tops is needed for animation, as part of the operation is saving the old location,
// which is needed for rows that are transitioning in
ServerSideRowModel.prototype.resetRowTops = function (cache) {
var numberSequence = new NumberSequence();
cache.forEachNodeDeep(function (rowNode) { return rowNode.clearRowTop(); }, numberSequence);
};
ServerSideRowModel.prototype.getRow = function (index) {
if (this.cacheExists()) {
return this.rootNode.childrenCache.getRow(index);
var rootStore = this.getRootStore();
if (!rootStore) {
return null;
}
return null;
return rootStore.getRowUsingDisplayIndex(index);
};
ServerSideRowModel.prototype.expandAll = function (value) {
// if we don't pause store updating, we are needlessly
// recalculating row-indexes etc, and also getting rendering
// engine to re-render (listens on ModelUpdated event)
this.pauseStoreUpdateListening = true;
this.forEachNode(function (node) {
if (node.group) {
node.setExpanded(value);
}
});
this.pauseStoreUpdateListening = false;
this.onStoreUpdated();
};
ServerSideRowModel.prototype.refreshAfterFilter = function (newFilterModel, params) {
if (this.storeParams) {
this.storeParams.filterModel = newFilterModel;
}
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.refreshAfterFilter(params);
this.onStoreUpdated();
};
ServerSideRowModel.prototype.getRootStore = function () {
if (this.rootNode && this.rootNode.childStore) {
return this.rootNode.childStore;
}
};
ServerSideRowModel.prototype.getRowCount = function () {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
return 1;
}
var serverSideCache = this.rootNode.childrenCache;
var res = serverSideCache.getDisplayIndexEnd();
return res;
return rootStore.getDisplayIndexEnd();
};
ServerSideRowModel.prototype.getTopLevelRowCount = function () {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
return 1;
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getVirtualRowCount();
return rootStore.getRowCount();
};
ServerSideRowModel.prototype.getTopLevelRowDisplayedIndex = function (topLevelIndex) {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
return topLevelIndex;
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getTopLevelRowDisplayedIndex(topLevelIndex);
return rootStore.getTopLevelRowDisplayedIndex(topLevelIndex);
};
ServerSideRowModel.prototype.getRowBounds = function (index) {
if (!this.cacheExists()) {
var rootStore = this.getRootStore();
if (!rootStore) {
var rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber();
return {
rowTop: 0,
rowHeight: this.rowHeight
rowHeight: rowHeight
};
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getRowBounds(index);
return rootStore.getRowBounds(index);
};
ServerSideRowModel.prototype.getRowIndexAtPixel = function (pixel) {
if (pixel === 0) {
var rootStore = this.getRootStore();
if (pixel <= 0 || !rootStore) {
return 0;
}
if (!this.cacheExists()) {
return 0;
}
var serverSideCache = this.rootNode.childrenCache;
return serverSideCache.getRowIndexAtPixel(pixel);
return rootStore.getRowIndexAtPixel(pixel);
};
ServerSideRowModel.prototype.getCurrentPageHeight = function () {
return this.rowHeight * this.getRowCount();
};
ServerSideRowModel.prototype.isEmpty = function () {

@@ -423,3 +306,3 @@ return false;

ServerSideRowModel.prototype.isRowsToRender = function () {
return this.cacheExists() && this.getRowCount() > 0;
return this.getRootStore() != null && this.getRowCount() > 0;
};

@@ -430,20 +313,31 @@ ServerSideRowModel.prototype.getType = function () {

ServerSideRowModel.prototype.forEachNode = function (callback) {
if (this.cacheExists()) {
this.rootNode.childrenCache.forEachNodeDeep(callback);
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
rootStore.forEachNodeDeep(callback);
};
ServerSideRowModel.prototype.executeOnCache = function (route, callback) {
if (!this.cacheExists()) {
ServerSideRowModel.prototype.executeOnStore = function (route, callback) {
var rootStore = this.getRootStore();
if (!rootStore) {
return;
}
var topLevelCache = this.rootNode.childrenCache;
var cacheToPurge = topLevelCache.getChildCache(route);
if (cacheToPurge) {
callback(cacheToPurge);
var storeToExecuteOn = rootStore.getChildStore(route);
if (storeToExecuteOn) {
callback(storeToExecuteOn);
}
};
ServerSideRowModel.prototype.purgeCache = function (route) {
if (route === void 0) { route = []; }
this.executeOnCache(route, function (cache) { return cache.purgeCache(); });
ServerSideRowModel.prototype.refreshStore = function (params) {
if (params === void 0) { params = {}; }
var route = params.route ? params.route : [];
this.executeOnStore(route, function (store) { return store.refreshStore(params.purge == true); });
};
ServerSideRowModel.prototype.getStoreState = function () {
var res = [];
var rootStore = this.getRootStore();
if (rootStore) {
rootStore.addStoreStates(res);
}
return res;
};
ServerSideRowModel.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {

@@ -453,3 +347,3 @@ if (_.exists(lastInRange) && firstInRange.parent !== lastInRange.parent) {

}
return firstInRange.parent.childrenCache.getRowNodesInRange(lastInRange, firstInRange);
return firstInRange.parent.childStore.getRowNodesInRange(lastInRange, firstInRange);
};

@@ -468,9 +362,2 @@ ServerSideRowModel.prototype.getRowNode = function (id) {

};
ServerSideRowModel.prototype.getBlockState = function () {
if (this.rowNodeBlockLoader) {
return this.rowNodeBlockLoader.getBlockState();
}
return null;
};
// always returns true - this is used by the
ServerSideRowModel.prototype.isRowPresent = function (rowNode) {

@@ -480,104 +367,3 @@ var foundRowNode = this.getRowNode(rowNode.id);

};
ServerSideRowModel.prototype.extractSortModel = function () {
var sortModel = this.sortController.getSortModel();
// when using tree data we just return the sort model with the 'ag-Grid-AutoColumn' as is, i.e not broken out
// into it's constitute group columns as they are not defined up front and can vary per node.
if (this.gridOptionsWrapper.isTreeData()) {
return sortModel;
}
var rowGroupCols = this.toValueObjects(this.columnController.getRowGroupColumns());
// find index of auto group column in sort model
var autoGroupIndex = -1;
for (var i = 0; i < sortModel.length; ++i) {
if (sortModel[i].colId === Constants.GROUP_AUTO_COLUMN_ID) {
autoGroupIndex = i;
break;
}
}
// replace auto column with individual group columns
if (autoGroupIndex > -1) {
var individualGroupCols = rowGroupCols.map(function (group) {
return {
colId: group.id,
sort: sortModel[autoGroupIndex].sort
};
});
// remove auto group column
sortModel.splice(autoGroupIndex, 1);
var _loop_1 = function (i) {
var individualGroupCol = individualGroupCols[i];
// don't add individual group column if non group column already exists as it gets precedence
var sameNonGroupColumnExists = sortModel.some(function (sm) { return sm.colId === individualGroupCol.colId; });
if (sameNonGroupColumnExists) {
return "continue";
}
sortModel.splice(autoGroupIndex++, 0, individualGroupCol);
};
// insert individual group columns
for (var i = 0; i < individualGroupCols.length; i++) {
_loop_1(i);
}
}
// strip out multi-column prefix on colId's
if (this.gridOptionsWrapper.isGroupMultiAutoColumn()) {
var multiColumnPrefix = Constants.GROUP_AUTO_COLUMN_ID + "-";
for (var i = 0; i < sortModel.length; ++i) {
if (sortModel[i].colId.indexOf(multiColumnPrefix) > -1) {
sortModel[i].colId = sortModel[i].colId.substr(multiColumnPrefix.length);
}
}
}
return sortModel;
};
ServerSideRowModel.prototype.isSortingWithValueColumn = function (changedColumnsInSort) {
var valueColIds = this.columnController.getValueColumns().map(function (col) { return col.getColId(); });
for (var i = 0; i < changedColumnsInSort.length; i++) {
if (valueColIds.indexOf(changedColumnsInSort[i]) > -1) {
return true;
}
}
return false;
};
ServerSideRowModel.prototype.isSortingWithSecondaryColumn = function (changedColumnsInSort) {
if (!this.columnController.getSecondaryColumns()) {
return false;
}
var secondaryColIds = this.columnController.getSecondaryColumns().map(function (col) { return col.getColId(); });
for (var i = 0; i < changedColumnsInSort.length; i++) {
if (secondaryColIds.indexOf(changedColumnsInSort[i]) > -1) {
return true;
}
}
return false;
};
ServerSideRowModel.prototype.cacheExists = function () {
return _.exists(this.rootNode) && _.exists(this.rootNode.childrenCache);
};
ServerSideRowModel.prototype.createDetailNode = function (masterNode) {
if (_.exists(masterNode.detailNode)) {
return masterNode.detailNode;
}
var detailNode = new RowNode();
this.getContext().createBean(detailNode);
detailNode.detail = true;
detailNode.selectable = false;
detailNode.parent = masterNode;
if (_.exists(masterNode.id)) {
detailNode.id = 'detail_' + masterNode.id;
}
detailNode.data = masterNode.data;
detailNode.level = masterNode.level + 1;
var defaultDetailRowHeight = 200;
var rowHeight = this.gridOptionsWrapper.getRowHeightForNode(detailNode).height;
detailNode.rowHeight = rowHeight ? rowHeight : defaultDetailRowHeight;
masterNode.detailNode = detailNode;
return detailNode;
};
ServerSideRowModel.prototype.isLoading = function () {
return this.rowNodeBlockLoader ? this.rowNodeBlockLoader.isLoading() : false;
};
__decorate([
Autowired('gridOptionsWrapper')
], ServerSideRowModel.prototype, "gridOptionsWrapper", void 0);
__decorate([
Autowired('columnController')

@@ -601,5 +387,11 @@ ], ServerSideRowModel.prototype, "columnController", void 0);

__decorate([
PostConstruct
], ServerSideRowModel.prototype, "postConstruct", null);
Autowired('ssrmSortService')
], ServerSideRowModel.prototype, "sortListener", void 0);
__decorate([
Autowired('ssrmNodeManager')
], ServerSideRowModel.prototype, "nodeManager", void 0);
__decorate([
Autowired('ssrmStoreFactory')
], ServerSideRowModel.prototype, "storeFactory", void 0);
__decorate([
PreDestroy

@@ -611,4 +403,7 @@ ], ServerSideRowModel.prototype, "destroyDatasource", null);

__decorate([
PostConstruct
], ServerSideRowModel.prototype, "addEventListeners", null);
__decorate([
PreDestroy
], ServerSideRowModel.prototype, "destroyRowNodeBlockLoader", null);
], ServerSideRowModel.prototype, "destroyRootStore", null);
ServerSideRowModel = __decorate([

@@ -615,0 +410,0 @@ Bean('rowModel')

import { ModuleNames } from "@ag-grid-community/core";
import { EnterpriseCoreModule } from "@ag-grid-enterprise/core";
import { ServerSideRowModel } from "./serverSideRowModel/serverSideRowModel";
import { StoreUtils } from "./serverSideRowModel/stores/storeUtils";
import { BlockUtils } from "./serverSideRowModel/blocks/blockUtils";
import { NodeManager } from "./serverSideRowModel/nodeManager";
import { TransactionManager } from "./serverSideRowModel/transactionManager";
import { ExpandListener } from "./serverSideRowModel/listeners/expandListener";
import { SortListener } from "./serverSideRowModel/listeners/sortListener";
import { FilterListener } from "./serverSideRowModel/listeners/filterListener";
import { StoreFactory } from "./serverSideRowModel/stores/storeFactory";
import { ListenerUtils } from "./serverSideRowModel/listeners/listenerUtils";
export var ServerSideRowModelModule = {
moduleName: ModuleNames.ServerSideRowModelModule,
rowModels: { 'serverSide': ServerSideRowModel },
rowModels: { serverSide: ServerSideRowModel },
beans: [ExpandListener, SortListener, StoreUtils, BlockUtils, NodeManager, TransactionManager,
FilterListener, StoreFactory, ListenerUtils],
dependantModules: [

@@ -8,0 +19,0 @@ EnterpriseCoreModule

{
"name": "@ag-grid-enterprise/server-side-row-model",
"version": "24.1.0",
"version": "25.0.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components",

@@ -45,4 +45,4 @@ "main": "./dist/cjs/main.js",

"dependencies": {
"@ag-grid-community/core": "~24.1.0",
"@ag-grid-enterprise/core": "~24.1.0"
"@ag-grid-community/core": "~25.0.0",
"@ag-grid-enterprise/core": "~25.0.0"
},

@@ -49,0 +49,0 @@ "devDependencies": {

@@ -13,3 +13,3 @@

[Angular 1](https://www.ag-grid.com/angular-grid/) | [Angular 2](https://www.ag-grid.com/angular-grid/) | [Javascript](https://www.ag-grid.com/javascript-grid/) | [Polymer](https://www.ag-grid.com/best-polymer-data-grid/) | [React](https://www.ag-grid.com/react-grid/) | [TypeScript](https://www.ag-grid.com/ag-grid-building-typescript/) | [VueJS](https://www.ag-grid.com/vuejs-grid/) | [Web Components](https://www.ag-grid.com/best-web-component-data-grid/) | [Aurelia](https://www.ag-grid.com/best-aurelia-data-grid/)
[Angular 1](https://www.ag-grid.com/documentation/angular/angularjs/) | [Angular 2](https://www.ag-grid.com/documentation/angular/getting-started/) | [Javascript](https://www.ag-grid.com/documentation/javascript/getting-started/) | [Polymer](https://www.ag-grid.com/documentation/javascript/polymer-getting-started/) | [React](https://www.ag-grid.com/documentation/react/getting-started/) | [TypeScript](https://www.ag-grid.com/documentation/javascript/building-typescript/) | [VueJS](https://www.ag-grid.com/documentation/vue/getting-started/)

@@ -16,0 +16,0 @@ This is not free software, this software is covered by copyright and to use you need a commercial license.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc