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

[Feature Request]: DataTable sortRow - pass rowIds to sortRow #13208

Closed
1 task done
justindm234 opened this issue Feb 22, 2023 · 0 comments · Fixed by #13236
Closed
1 task done

[Feature Request]: DataTable sortRow - pass rowIds to sortRow #13208

justindm234 opened this issue Feb 22, 2023 · 0 comments · Fixed by #13236

Comments

@justindm234
Copy link

The problem

Occasionally, the sorting of a column depends on more than just the cell display value. Other row/state data may be needed to perform the sort.

The product I work on supports the notion of "acceptable" status values. This allows customers to ignore anticipated hardware/software errors during maintainence windows. To indicate this, our user interface displays an "acceptable" icon in status cells - a red 'x' indicates the status is unacceptable and a green checkmark indicates the status is acceptable.

image

We historically sort our status columns by acceptability and then by status text. However, the existing carbon DataTable sortRow function does not provide the information needed to do this. We need sortRow to also provide the IDs of the rows being sorted so we can check row/object acceptability.

The solution

Add the rowIds ([a, b]) to the object param passed to sortRow functions - https://github.com/carbon-design-system/carbon/blob/main/packages/react/src/components/DataTable/tools/sorting.js#L97

Examples

  rowIds.slice().sort((a, b) => {
    const cellA = cellsById[getCellId(a, key)];
    const cellB = cellsById[getCellId(b, key)];
    return sortRow(cellA && cellA.value, cellB && cellB.value, {
      key,
      sortDirection,
      locale,
      sortStates,
      compare,
      **rowIds: [a, b]**
    });
  });

Application/PAL

zSystems Hardware Management Console

Business priority

Medium Priority = upcoming release but is not pressing

Available extra resources

No response

Code of Conduct

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

Successfully merging a pull request may close this issue.

1 participant