jbetancur / react-data-table-component

A responsive table library with built-in sorting, pagination, selection, expandable rows, and customizable styling.
https://react-data-table-component.netlify.app
Apache License 2.0
2.04k stars 411 forks source link

SortField vs Column Interface: Having an explicit sortField on column was confusing to me. #1179

Open AlexMoutonNoble opened 10 months ago

AlexMoutonNoble commented 10 months ago

Feature Check list

Hi JBetancur and all. Long time listener...

I notice looking at the code and docs that there's no requirement in the code that sortField be a string and beyond that it isn't "strictly necessary" in RDTC since the column type is typed as an interface. I was confused by sortField being there since it is so close to sortFieldId but does not participate in that system.

Could the column be typed in a way that retains full knowledge of that type when returned to onSort, TableColumn.cell etc? maybe export type TableProps<T, Column extends TableColumn<T>= TableColumn<T>>? This would resolve sortField, but also make things like Column based rendering more available in the system. (Its already possible, but not mentioned anywhere, as far as I can tell)

Would be happy to make a PR if thats interesting.

Thanks for your hard work Alex Mouton