angular / angular/components

MatTableDataSource.sortingDataAccessor needs sortDirection

Offen
#13,377 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/table feature P4
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### Bug, feature request, or proposal:

Feature request

Enhance MatTableDataSource.sortingDataAccessor with sortDirection parameter to allow for better sort customization.

#### What is the expected behavior?

For example being able to define a sortingDataAccessor to *always* sort NULL values to the bottom (or top for that matter) regardless if 'asc' or 'desc'

#### What is the current behavior?

Null values are interpreted as 0 (zero) in case of numeric properties.

#### What are the steps to reproduce?

https://angular-8ubc1i.stackblitz.io

#### What is the use-case or motivation for changing an existing behavior?

I have a list of objects with various numeric properties, some of which are NULL.

I'd like to write a sortingDataAccessor to ALWAYS sort NULL values to the bottom regardless of 'asc' or 'desc' (since NULL is irrelevant/meaningless for our sort)
For this I seem to need a sortDirection in the sortingDataAccessor to either return min or max 'infinity' for NULL values.

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?

6.4.7

#### Is there anything else we should know?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Finde MatTableDataSource und dessen Implementierung von sortingDataAccessor, und reproduziere anschließend das Verhalten im verlinkten StackBlitz-Beispiel. Bestätige, dass der vorgeschlagene Accessor die Sortierrichtung verwenden kann, sodass NULL-Werte sowohl bei aufsteigender als auch bei absteigender Sortierung konsistent unten oder oben bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.