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

feat: add DataTable display and sort methods #352

Merged
merged 3 commits into from
Oct 21, 2020
Merged

feat: add DataTable display and sort methods #352

merged 3 commits into from
Oct 21, 2020

Conversation

albertms10
Copy link
Contributor

fixes #282


  • feat: add display and sort methods in header object
  • feat: update types and Component Index
  • feat: update Public API with datatable headers methods

@albertms10 albertms10 requested a review from metonym as a code owner October 21, 2020 21:46
@vercel
Copy link

vercel bot commented Oct 21, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/carbon-svelte/carbon-components-svelte/k29fd5tfm
✅ Preview: https://carbon-components-svelte-git-datatable-display-sort.carbon-svelte.vercel.app

@@ -231,7 +241,9 @@
dispatch('click:cell', cell);
}}"
>
<slot name="cell" row="{row}" cell="{cell}">{cell.value}</slot>
<slot name="cell" row="{row}" cell="{cell}">
{headers[j].display ? headers[j].display(cell.value) : cell.value}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the display method be accessed this way—referencing the original headers array—or by passing it to the cells object?

https://github.com/IBM/carbon-components-svelte/blob/ead9634ab641ce50b13046604687164ee86be8cd/src/DataTable/DataTable.svelte#L119-L122

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you have is good

const sortHeader = writable({
id: null,
key: null,
sort: undefined,
Copy link
Contributor Author

@albertms10 albertms10 Oct 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should sort be initialized with null instead of undefined, like the other sortHeader properties?

Copy link
Collaborator

@metonym metonym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! This feature makes the DataTable very flexible.

Now, you'd be able to:

  • customize display/sorting per header as needed
  • customize cell value with markup/components using named slots

Can't wait to start using this.

@metonym metonym merged commit e67272f into carbon-design-system:master Oct 21, 2020
@albertms10 albertms10 deleted the datatable-display-sort branch October 24, 2020 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add custom DataTable sorting method
2 participants