Skip to content

GridCore data: Merge DataHelperMixin into DataController - #34938

Merged
bit-byte0 merged 11 commits into
DevExpress:mainfrom
bit-byte0:refactor/gridcore-datacontroller-merge-datahelper-mixin-26_2
Aug 28, 2026
Merged

GridCore data: Merge DataHelperMixin into DataController#34938
bit-byte0 merged 11 commits into
DevExpress:mainfrom
bit-byte0:refactor/gridcore-datacontroller-merge-datahelper-mixin-26_2

Conversation

@bit-byte0

@bit-byte0 bit-byte0 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What

Removes the grid_core-only DataHelperMixin and folds its data-source lifecycle logic directly into DataController, so the controller no longer carries unused generic mixin machinery. Also fixes a pre-existing case where the shared-data-source flag stayed set after switching to a non-shared source

How

Inlined the live parts (postInit, _refreshDataSource, ready-watcher wiring) into data_controller.ts and dropped the dead generic paths that grid_core never exercised. The raw DataSource is now built by a local _createRawDataSource helper so _dataSource only ever holds the adapter, and _isSharedDataSource is now assigned on every path

Copilot AI lite review requested due to automatic review settings August 26, 2026 19:54
@bit-byte0
bit-byte0 requested a review from a team as a code owner August 26, 2026 19:54
@bit-byte0 bit-byte0 added the 26_2 label Aug 26, 2026
@bit-byte0 bit-byte0 self-assigned this Aug 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the grid_core-specific DataHelperMixin and folds its remaining data-source lifecycle responsibilities into grid_core’s DataController, reducing reliance on generic mixin plumbing and making DataController the single place that wires data-source readiness/disposal behavior.

Changes:

  • Removed DataHelperMixin and stopped extending it from DataController.
  • Inlined data-source lifecycle hooks into DataController (init/refresh + ready-watcher wiring) and introduced _createRawDataSource() to construct the raw DataSource before adapter wrapping.
  • Updated search code to read langParams via getDataSource() directly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/devextreme/js/__internal/grids/grid_core/search/m_search.ts Adjusts how langParams is retrieved (via getDataSource()), aligning with the removal of the mixin-held controller path.
packages/devextreme/js/__internal/grids/grid_core/data_controller/data_helper_mixin.ts Removes the mixin implementation entirely.
packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts Integrates the mixin’s data-source lifecycle setup into DataController and adds _createRawDataSource() + ready-watcher wiring.
Suppressed comments (1)

packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts:716

  • _createRawDataSource() disposes the previous adapter but doesn’t unsubscribe readyWatcher from the previous raw DataSource, and it never clears _isSharedDataSource after disposal. If the previous dataSource was shared and the new one is not, the stale _isSharedDataSource flag can cause future adapters to be disposed as “shared” (skipping dispose) and the loadingChanged subscription can leak. Detach the listener before disposing and reset _isSharedDataSource after disposal.
  private _createRawDataSource(): DataSource | undefined {
    const dataSourceOptions = this._getSpecificDataSourceOption();

    this._disposeDataSource();


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 27, 2026 08:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Comment on lines +76 to +78
protected readyWatcher?: (isLoading: boolean) => void;

protected _ready?: (value?: boolean) => void;

@Tucchhaa Tucchhaa Aug 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the 'ready' callback is never set and used. If that's true, let's remove readyWatcher and _ready

Comment on lines +721 to +723
const isSharedDataSource = dataSourceOptions instanceof DataSourceClass;

this._isSharedDataSource = isSharedDataSource;

@Tucchhaa Tucchhaa Aug 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional code-style suggestion, use just this._isSharedDataSource prop and delete var:

this._isSharedDataSource = dataSourceOptions instanceof DataSourceClass;

Comment on lines +679 to +683
public postInit(): void {
this.on('disposing', () => {
this._disposeDataSource();
});
}

@Tucchhaa Tucchhaa Aug 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need postInit() method? I see that dataController.dispose() already calls _disposeDataSource()

/**
* @extended: state_storing, virtual_scrolling
*/
protected _refreshDataSource(): DeferredObj<unknown> | undefined {

@Tucchhaa Tucchhaa Aug 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about renaming the method to resetDataSource()?
I think that name expresses what this function does more clearly than the current name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't object about it


protected _calculateAdditionalFilter(): DataFilter {
const dataSource = this._dataController?.getDataSource?.();
const dataSource = this.getDataSource?.();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 this.getDataSource();

Copilot AI review requested due to automatic review settings August 27, 2026 12:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts:708

  • When the dataSource option is cleared (null/undefined/0/''), _createRawDataSource returns early without updating _isSharedDataSource, so the flag can retain the previous value even though there is no current data source. This makes _isSharedDataSource reflect stale state and can lead to confusing behavior for any code/tests that reads it after clearing the dataSource.
    if (!dataSourceOptions) {
      return undefined;
    }

}
}

private _createRawDataSource(): DataSource | undefined {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove _ for added fields and methods (except _dataSource may be - if it assumes multiple changes through code base)

const dataSource = (isSharedDataSource
? dataSourceOptions
: new DataSourceClass(
extend(true, {}, normalizeDataSourceOptions(dataSourceOptions, { fromUrlLoadMode: false })),

@anna-shakhova anna-shakhova Aug 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit difficult to read, after readyWatcher removed, then lets use early return

  • { fromUrlLoadMode: false } is excessive, empty options object can be passed
Suggested change
extend(true, {}, normalizeDataSourceOptions(dataSourceOptions, { fromUrlLoadMode: false })),
extend(true, {}, normalizeDataSourceOptions(dataSourceOptions, {})),

}
}

private _createRawDataSource(): DataSource | undefined {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect naming - this method not only creates new raw data source, but also disposes existing one

Copilot AI review requested due to automatic review settings August 27, 2026 13:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

packages/devextreme/js/__internal/grids/grid_core/data_controller/tests/data_controller.data_source.test.ts:55

  • After changing the dataSource option, the controller update/load cycle is async in these tests. Add await flushAsync() before asserting on internal controller state to avoid flaky timing-dependent failures.
      instance.option('dataSource', DATA);

      expect(getIsSharedDataSource(instance)).toBe(false);

Tucchhaa
Tucchhaa previously approved these changes Aug 27, 2026
…re on isSharedDataSource, reset flag on every path
Copilot AI review requested due to automatic review settings August 27, 2026 14:22
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 27, 2026
Tucchhaa
Tucchhaa previously approved these changes Aug 28, 2026
@bit-byte0
bit-byte0 added this pull request to the merge queue Aug 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 28, 2026
@bit-byte0
bit-byte0 added this pull request to the merge queue Aug 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 28, 2026
Copilot AI review requested due to automatic review settings August 28, 2026 07:55
@bit-byte0
bit-byte0 dismissed stale reviews from Tucchhaa and anna-shakhova via dab679e August 28, 2026 07:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings August 28, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Tucchhaa
Tucchhaa previously approved these changes Aug 28, 2026
anna-shakhova
anna-shakhova previously approved these changes Aug 28, 2026
Copilot AI review requested due to automatic review settings August 28, 2026 08:33
@bit-byte0
bit-byte0 dismissed stale reviews from anna-shakhova and Tucchhaa via 7eda658 August 28, 2026 08:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@bit-byte0
bit-byte0 added this pull request to the merge queue Aug 28, 2026
Merged via the queue into DevExpress:main with commit a5d793b Aug 28, 2026
116 of 117 checks passed
@bit-byte0
bit-byte0 deleted the refactor/gridcore-datacontroller-merge-datahelper-mixin-26_2 branch August 28, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants