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

Pin multiple columns #537

Open
noxan opened this issue Jan 31, 2024 · 2 comments
Open

Pin multiple columns #537

noxan opened this issue Jan 31, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@noxan
Copy link

noxan commented Jan 31, 2024

Describe the solution you'd like
We would love to pin multiple columns (to the left), think of firstname and lastname as two dedicated columns (for sorting) and we would love for both of them to remain sticky on the left (horizontal scrolling).

Describe alternatives you've considered
Was thinking of merging the two columns, but that would break sorting. Alternative would be grouping them, but the docs says that does not work either.

Additional context
While looking for other people who might have reported something similar, I stumbled across https://v2.mantine-react-table.com/docs/guides/column-pinning which supports pinning multiple columns - I prefer the styling and UX of this project, so would prefer not migrating - just as inspiration :)

@icflorescu
Copy link
Owner

This is indeed a highly desired feature, that has been required and discussed before, see #229 and #477 or #347.
At the moment I don't have enough resources to dedicate to this, but, as I mentioned before, I'm 100% open to a PR:

it would be fantastic if someone would provide some help with scaling this to something like pinLeftColumns: number and pinRightColumns: number.

I think it could be implemented by dynamically computing the size of the pinned columns at render time.
Here are some code starting points:

const { ref: selectionColumnHeaderRef, width: selectionColumnWidth } = useElementOuterSize<HTMLTableCellElement>();

And the CSS to render the scroll shadows as needed, which is a bit convoluted and tricky:

https://github.com/icflorescu/mantine-datatable/blob/f8a40149f4a12b2e023cc81e2572ad493edc3342/package/DataTable.css#L101-L242

@icflorescu icflorescu added enhancement New feature or request help wanted Extra attention is needed labels Jan 31, 2024
@icflorescu icflorescu pinned this issue Jan 31, 2024
@icflorescu
Copy link
Owner

Just to clarify things for anyone bumping into this: it's not trivial but it can be done.
I'll address it at some point in the future, I just don't have the time/resources to do so now.

You can help speed up the process by:

  • either giving it a try in a PR
  • or, if your company is using Mantine DataTable and can afford it, sponsoring the development of the feature (drop me a message at the email address listed in my GitHub profile before) or hiring my services

@icflorescu icflorescu unpinned this issue Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants