Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table calls sortInternalRows with externalSorting=true #1470

Open
dmartin-gh opened this issue Jun 27, 2018 · 6 comments
Open

Table calls sortInternalRows with externalSorting=true #1470

dmartin-gh opened this issue Jun 27, 2018 · 6 comments

Comments

@dmartin-gh
Copy link

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

When externalSorting is enabled, the sortInternalRows() method is still called due to this commit: 67a4e8a This causes the rows to change their sort order in undesirable ways after they are passed to the datatable component. Single sorting seems to work fine, but when combined with [sortType]="'multi'" the sort order is incorrect.

I believe the additional call to sortInternalRows() added to the translateColumns() method should be changed to:

if (!this.externalSorting) {
    this.sortInternalRows();
}

Expected behavior

Multi sorting would work correctly with externalSorting=true and the grid would never attempt to sort the rows itself.

Reproduction of the problem

Turn on [externalSorting]="true" and [sortType]="'multi'" and see that the sortInternalRows() method is called.

Please tell us about your environment:

  • Table version: 11.3.0
  • Angular version: 5.2.4
  • Browser: Chrome 67.0.3396.99
  • Language: TypeScript 2.5.3
@ronsc
Copy link

ronsc commented Aug 1, 2018

How i can workaround for fix this issue @dmartinzar

@lecongbang90
Copy link

@dmartinzar, @ronsc . I have same issue. Anyone fixed it?
Support me, many thank!!!

@mc-suchecki
Copy link

We have the same issue in our application. I can confirm that downgrading the dependency to 11.2.0 (bug was introduced in 11.3.0) fixes the issue. Can somebody take a look at this? Do you accept PRs on that?

@mc-suchecki
Copy link

As nobody from the ngx-datatable seems to answer this issue, I downgraded the package to 11.2.0. However, I quickly discovered that this creates another bug in my app. The fix for it was merged in 13.0.1: #1375

Moreover, in our case the sorting issue exists even with [sortType] set to 'single'.

Therefore, I came up with the workaround - define a Noop comparator like so:

   <ngx-datatable-column
      ...
     [comparator]="noopComparator"
     ...
>
 public noopComparator(): number {
    return 0;
 }

This looks bad, but fixes the issue, allowing us to use the latest version. We can remove rxjs-compat now by the way. 👍

I hope this helps @dmartinzar @ronsc @lecongbang90!

@DzmVasileusky
Copy link

This issue also affects [sorts] input. For example if you are sorting a table from outside and then want to apply correct view state to column header.
[externalSorting]="true" [sorts]="externalSort$ | async" will cause client side sorting.

@cyrilfr
Copy link

cyrilfr commented Sep 6, 2024

I have the same issue. Are there any plans now to fix it someday?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants