Skip to content

Commit

Permalink
DataGrid - Performance drops on adding a large number of rows via ed…
Browse files Browse the repository at this point in the history
…iting.changes (T1251098) (#28392)
  • Loading branch information
tongsonbarbs authored Nov 21, 2024
1 parent 9502543 commit 827fc37
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import domAdapter from '@js/core/dom_adapter';
import Guid from '@js/core/guid';
import type { dxElementWrapper } from '@js/core/renderer';
import $ from '@js/core/renderer';
import { equalByValue } from '@js/core/utils/common';
// @ts-expect-error
import { equalByValue, getKeyHash } from '@js/core/utils/common';
import type { DeferredObj } from '@js/core/utils/deferred';
// @ts-expect-error
import { Deferred, fromPromise, when } from '@js/core/utils/deferred';
Expand Down Expand Up @@ -131,7 +132,7 @@ class EditingControllerImpl extends modules.ViewController {

protected _saveEditorHandler: any;

private _internalState: any;
private _internalState!: Map<unknown, any>;

protected _refocusEditCell: any;

Expand Down Expand Up @@ -193,7 +194,7 @@ class EditingControllerImpl extends modules.ViewController {
this._updateEditButtons();

if (!this._internalState) {
this._internalState = [];
this._internalState = new Map();
}

this.component._optionsByReference[EDITING_EDITROWKEY_OPTION_NAME] = true;
Expand Down Expand Up @@ -272,7 +273,7 @@ class EditingControllerImpl extends modules.ViewController {
}

private _getInternalData(key) {
return this._internalState.filter((item) => equalByValue(item.key, key))[0];
return this._internalState.get(getKeyHash(key));
}

public _addInternalData(params) {
Expand All @@ -282,7 +283,7 @@ class EditingControllerImpl extends modules.ViewController {
return extend(internalData, params);
}

this._internalState.push(params);
this._internalState.set(getKeyHash(params.key), params);
return params;
}

Expand Down Expand Up @@ -1329,12 +1330,7 @@ class EditingControllerImpl extends modules.ViewController {
}

private _removeInternalData(key) {
const internalData = this._getInternalData(key);
const index = this._internalState.indexOf(internalData);

if (index > -1) {
this._internalState.splice(index, 1);
}
this._internalState.delete(getKeyHash(key));
}

private _updateInsertAfterOrBeforeKeys(changes, index) {
Expand Down Expand Up @@ -1770,8 +1766,7 @@ class EditingControllerImpl extends modules.ViewController {
return deferred.promise();
}

// @ts-expect-error
private _resolveAfterSave(deferred, { cancel, error } = {}) {
private _resolveAfterSave(deferred, { cancel = undefined, error = undefined } = {}) {
// @ts-expect-error
when(this._afterSaveEditData(cancel)).done(() => {
deferred.resolve(error);
Expand Down Expand Up @@ -1860,7 +1855,6 @@ class EditingControllerImpl extends modules.ViewController {
}).done(() => {
this._resolveAfterSave(deferred);
}).fail((error) => {
// @ts-expect-error
this._resolveAfterSave(deferred, { error });
});
}
Expand Down

0 comments on commit 827fc37

Please sign in to comment.