Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

feat(DataTable): Add sorting params to header onClick callback #2083

Merged
merged 7 commits into from
Mar 27, 2019
Merged

feat(DataTable): Add sorting params to header onClick callback #2083

merged 7 commits into from
Mar 27, 2019

Conversation

moczolaszlo
Copy link
Contributor

With this change the callback of DataTable header's onClick gives back the params of sorting as an object.
Like:

{
  sortHeaderKey: 'name',
  sortDirection: 'DESC,
}

New

  • Sorting params added to the callback function.

@netlify
Copy link

netlify bot commented Mar 22, 2019

Deploy preview for carbon-components-react ready!

Built with commit 008e7c2

https://deploy-preview-2083--carbon-components-react.netlify.com

@emyarod
Copy link
Member

emyarod commented Mar 22, 2019

hi @moczolaszlo it looks like CI is failing because the bundle size threshold needs to be increased https://github.com/IBM/carbon-components-react/blob/master/package.json#L365

on a side note, is there an associated issue for this pull request for additional context?

@moczolaszlo
Copy link
Contributor Author

Hi @emyarod
I updated the bundle size threshold, and I rebased the PR.
We need this parameters, because we want to sort a lot of data with paging.

onClick: composeEventHandlers([
this.handleSortBy(header.key),
onClick
? this.handleOnHeaderClick(onClick, header.key, sortDirection)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to gather sortkey/sortdirection in an object here, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this?

this.handleOnHeaderClick(onClick, {
  sortHeaderKey: header.key,
  sortDirection,
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes 👍

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

LGTM 👍 - Thanks @moczolaszlo!

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

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

awesome, thanks for doing this!

@asudoh asudoh merged commit e76d696 into carbon-design-system:master Mar 27, 2019
@carbon-bot
Copy link

🎉 This PR is included in version 6.112.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@akmalmzamri
Copy link

akmalmzamri commented Jul 11, 2020

Hi @moczolaszlo and @asudoh. I'm pretty new to React and Carbon. I'm trying to get both header's key and sort direction for my custom sort function. I have this onClick function:

<TableHeader
    {...getHeaderProps({header})}
    onClick={(e, sortParams) =>
        console.log(e, sortParams)
    }>

However, it seems that sortParams is undefined in the onClick function. Am I doing this wrong?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants