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

[Table] - Implement sortable function for TableColumn #196

Open
devminh opened this issue May 25, 2021 · 0 comments
Open

[Table] - Implement sortable function for TableColumn #196

devminh opened this issue May 25, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@devminh
Copy link
Contributor

devminh commented May 25, 2021

Hi, I believe this is an important function for a table.

From @thien-do suggestion, the idea would be:

  interface TableColumn {
   title:ReactNode;
   render: | keyof R // Accessor | ((row: R, index: number) => ReactNode);
   sortable: true | undefined | () => void;
}

if sortable === undefined: not thing happen

if sortable === “true” -> client side, internal sort

//Client-side sorting:
sortable: () => {
  const newData = data.sort(something);
  setData(newData);
}

//Server-side sorting:
sortable: () => {
  const newData = await getNewData({ sort: “abc” });
  setData(newData)
}

Sortable table column example:

https://material-ui.com/components/tables/

@lqt93 lqt93 added the enhancement New feature or request label May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants