question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug Report: Sorting with nested names in TdDataTableService.sortData

See original GitHub issue

Hi, Im using covalent 1.0.0-beta.5 and tried out the td-data-table with sorting capabilities. The problem I have is when we present data from a nested hierarchy (see example below) the sorting does not work.

Example: columns: ITdDataTableColumn[] = [ {name: 'commitRef.commitTime', label: 'Updated', tooltip: 'Updated', sortable: true, format: (value) => this.datePipe.transform(value, 'yyyy-MM-dd HH:mm:ss')}, {name: 'commitRef.committer.name', label: 'Changed by', tooltip: 'Changed by', sortable: true} ];

Then when calling sortData in TdDataTableService it doesn’t retrieve the value from nested properties.

https://github.com/Teradata/covalent/blob/4544c1a5bcabb1fa3e60b6fe6c2f6e1a5215ab5c/src/platform/core/data-table/services/data-table.service.ts#L45

In my case above this would resolve into a[“commitRef.commitTime”], where it actually should have been something like a[“commitRef”][“commitTime”]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
JoshSchoencommented, Jul 19, 2017

Took a look at this and came up with a possible solution. See the gif and the mock data structure. nested-data-table-sort [ { "score": { "value": 23, "level": "One level", "nested": { "value": 1, "level": "Two levels", "nested": { "value": 3, "level": "Three levels" } } }, "predicted": { "value": 45, "level": "One Level", "nested": { "value": 4, "level": "Two levels", "nested": { "value": 6, "level": "Three levels", "nested": { "value": 75, "level": "Four levels" } } } } }, { "score": { "value": 8, "level": "One level", "nested": { "value": 2, "level": "Two levels", "nested": { "value": 88, "level": "Three levels" } } }, "predicted": { "value": 10, "level": "One Level", "nested": { "value": 8, "level": "Two Levels", "nested": { "value": 10, "level": "Three levels", "nested": { "value": 2, "level": "Four levels" } } } } }, { "score": { "value": 6, "level": "One level", "nested": { "value": 89, "level": "Two levels", "nested": { "value": 44, "level": "Three levels" } } }, "predicted": { "value": 12, "level": "One Level", "nested": { "value": 3, "level": "Two Levels", "nested": { "value": 26, "level": "Three levels", "nested": { "value": 1, "level": "Four levels" } } } } }, { "score": { "value": 10, "level": "One level", "nested": { "value": 4, "level": "Two levels", "nested": { "value": 20, "level": "Three levels" } } }, "predicted": { "value": 22, "level": "One Level", "nested": { "value": 13, "level": "Two Levels", "nested": { "value": 96, "level": "Three levels", "nested": { "value": 14, "level": "Four levels" } } } } } ]

Let me know if this seems correct at least visually and I will refactor a bit, add it to the data table demo page and add the PR.

0reactions
jeremysmarttcommented, Sep 6, 2018

See PR #786 no longer needed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material 2 DataTable Sorting with nested objects
It was hard to find documentation on this, but it is possible by using sortingDataAccessor and a switch statement. For example:
Read more >
Sorting nested objects in Material Data Tables
Sorting the table by project name or company now works like a charm! Note: This data accessor function requires the full path to...
Read more >
Angular Default Sorting In Angular Material With Nested Objects
Starter project for Angular apps that exports to the Angular CLI.
Read more >
Table sorting and nested objects issue - Support
Table bound to “list” object sorts fine when column is bound to first level attribute e.g “list.currentItem.name”, however biding column to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found