ngx-datatable icon indicating copy to clipboard operation
ngx-datatable copied to clipboard

Sorting doesn't work on grouped rows

Open madmandrew opened this issue 7 years ago • 7 comments

[ 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 selecting a column to sort on a grouped table nothing happens
ie. in demo page http://swimlane.github.io/ngx-datatable/#
Gender (sort desc) -> data doesn't change
Gender (sort asc) -> data doesn't change

**Expected behavior**
When selecting a column to sort on data inside group sorted
ie. in demo page http://swimlane.github.io/ngx-datatable/#
Gender (sort desc) -> data in group should be ordered Female, Female, Male, Male,
Gender (sort asc) -> data doesn't change Male, Male, Female, Female


**Reproduction of the problem**
click on column sorting observe data in group

**What is the motivation / use case for changing the behavior?**
sorting consistency and expected behavior

**Please tell us about your environment:**
N/A

* **Table version:** 0.8.x
N/A

* **Angular version:** 2.0.x
N/A

* **Browser:** 
Chrome

* **Language:**
all

madmandrew avatar Mar 14 '18 23:03 madmandrew

Also I just discovered If I have class="striped" it doesn't work when grouping is on also. Could be a separate ticket?

madmandrew avatar Mar 15 '18 21:03 madmandrew

You can react to the (sort) event on the table and sort the grouped entries yourself.

BUT

For some reason, the sorting is not always using the order that is put in. If the input values for [rows] and [groupedRows] change (due to some filtering), some positions of rows seem to be cached and they are placed seemingly at random.

For example:

  • Order the elements ascendingly (by number), you get -1, 0, 1, 2
  • Filter elements that are >= 0, update [rows] and [groupedRows], change the sorting - the elements have order 2, 1, 0 but they are rendered in order of 1, 0, 2

It's often the first row that gets moved to the bottom, not always though. I haven't figured out a clear "rule" or reason behind this mismatch of element-order and render-order.

Phyrra avatar May 25 '18 14:05 Phyrra

+1

ghost avatar May 28 '18 05:05 ghost

Exactly same problem 8 months later. I personally solved it by doing a ngx-datable inside a ngx-datable. The first table is only one row with the sorting value and without header to keep the illusion.

Here is my code

https://codepen.io/SBackUp/pen/MzpzEv

BusoArnaud avatar Nov 14 '18 15:11 BusoArnaud

Still a problem with grouped sorting. doesn't work.

PureProp avatar Nov 27 '18 13:11 PureProp

Still a problem with grouped sorting. doesn't work. Even the current demo has sort and doesn't work, this lib is actually abandoned, dont know why they dont make it explicit.

d10n4t4n avatar Jun 23 '21 13:06 d10n4t4n

+1

gwin003 avatar Mar 28 '22 13:03 gwin003