enhancement
major
minor
major
minor
major
#29981
View layer: a table column cannot be declared unsortable, so the groups it forms cannot keep the order of their rows
Follow-up of #29812, observed with 8.0.0-alpha11 in E-Home (haumacher/ehome, catalogs/program.view.xml).
A grouped <table> orders its groups with the comparator of the grouping column. Since #29812 a column declares its own <comparator>; it compares two cell values and sees the inputs of the column (or of the table), but not the rows. A column whose displayed value has no order of its own (here: the title of a page of an application program, whose order is the position of the page in the program structure, given only by the order of the rows) cannot be ordered explicitly.
Workaround: <comparator>a -> b -> 0</comparator> - all groups rank equal and the stable sort of ListRowSource keeps them in the order of their first rows. This relies on the stability of the group sort, which is not documented.
ListRowSource already keeps the groups of a column that cannot sort in the order their first rows appear in, but a column of a .view.xml cannot declare that it does not sort: without a <comparator> it always takes the order derived from the type of its values.
Lösung
- <column>, <computed-column> und <dynamic-columns> bekommen sortable="false" (Standard true): Die Spalte bietet keine Sortierung an (keine Sortierung über den Spaltenkopf, eine gespeicherte Sortierung nach ihr wird ignoriert). Eine eingebettete Spalte übernimmt die Einstellung der Spalte, die sie einbettet. Zusammen mit sort oder <comparator> ist sortable="false" ein Konfigurationsfehler. Technisch: ColumnSetup#sortable(), DelegatingColumn.notSortable(Column).
- Eine Tabelle, die nach einer Spalte ohne Sortierung gruppiert ist, ordnet die Gruppen in der Reihenfolge der Zeilen, die sie erhält (erstes Auftreten des Gruppenwerts unter den gefilterten Zeilen), unabhängig davon, wonach der Benutzer sortiert; eine Sortierung ordnet nur die Zeilen innerhalb jeder Gruppe (ListRowSource). Bisher folgten die Gruppen dem ersten Auftreten in der sortierten Anzeige, so dass eine Sortierung nach einer anderen Spalte auch die Gruppen umordnete.
- Der Tabellen-Artikel (view-layer/tables) beschreibt, wie man Gruppen eines Werts ohne eigene Ordnung ordnet: nach dem Objekt gruppieren statt nach seinem Label (eine Seite statt ihres Titels - gleichnamige Objekte bleiben getrennt, und ein <comparator> kann die Position des Objekts lesen), die Gruppen per <comparator> mit Tabellen-Inputs ordnen (z.B. compare($pages.elementIndex($left), $pages.elementIndex($right))), oder sortable="false" für die Reihenfolge der Zeilen.
- Demo: tl-demo-react, Tabellenspalten → Reiter "Zeilenreihenfolge".