material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Type script update - add sortDirection parameter to customSort function

Open tian-lan-landing opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe.

No issue, only type update.

Describe the solution you'd like

Add optional parameter sortDirection to the customSort function here.

  customSort?: (
    data1: RowData,
    data2: RowData,
-   type: "row" | "group"
+   type: "row" | "group", 
+   sortDirection?: "desc",
  ) => number;

Describe alternatives you've considered

The data manager is actually passing three parameters or passing the fourth parameter with "desc", see codes here, so the type is currently sortDirection?: "desc". But it may be more comprehensive if the sortDirection is "asc" | "desc".

Additional context

I want the sort direction because I want some records to always be on the top. https://codesandbox.io/s/material-table-starter-template-forked-vhgps?file=/src/index.js

It works even in typescript without the proposed change, but it's better if hints comes from typescript itself.

tian-lan-landing avatar Nov 05 '21 05:11 tian-lan-landing

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Feb 05 '22 08:02 stale[bot]

@tian-lan-landing Could you reopen this issue? I'm looking for this feature as well. Your solution really helps

JeomJeom avatar Mar 17 '22 01:03 JeomJeom