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] Fixing head in material #6625

Closed
hassansidhu opened this issue Apr 16, 2017 · 37 comments · Fixed by #17139
Closed

[Table] Fixing head in material #6625

hassansidhu opened this issue Apr 16, 2017 · 37 comments · Fixed by #17139
Labels
component: table This is the name of the generic UI component, not the React module! new feature New feature or request priority: important This change can make a difference

Comments

@hassansidhu
Copy link

For Fixing table Head in material 1.0.0 11 alpha

I have a table with scrolling rows but I am not able to fix the header.
Is there a property to do so as fixedHeader was in material 0.15 and up but there doesnt seem to be something similar in 1.0.0 version

Versions

  • Material-UI: 1.0.0-alpha 11
  • React: 15.4.2
@mbrookes mbrookes added the component: table This is the name of the generic UI component, not the React module! label Apr 16, 2017
@nareshbhatia
Copy link
Contributor

I ran into the same issue today. Version 0.15 had the fixedHeader prop, v 1.x doesn't. I assume that there are plans to get this in.

@oliviertassinari oliviertassinari changed the title Fixing table Head in material 1.0.0 alpha [Table] Fixing head in material 1.0.0 alpha Jun 24, 2017
@oliviertassinari oliviertassinari added the new feature New feature or request label Jun 24, 2017
@oliviertassinari oliviertassinari changed the title [Table] Fixing head in material 1.0.0 alpha [Table] Fixing head in material Jul 30, 2017
@slim-hmidi
Copy link
Contributor

Same problem with Material-ui v1.0.0-beta.16.

@kallebornemark
Copy link
Contributor

Would be really nice to have this feature back!

@mariorubinas
Copy link

Same problem with Material-ui v1.0.0-beta.33

This is a must have feature! I think anyone who works with data grids would agree with me.

@mbrookes
Copy link
Member

@mariorubinas If this feature is important to you, please consider submitting a PR. You can use this issue if you'd like to discuss your approach.

@asrane
Copy link

asrane commented Mar 12, 2018

This is a must have feature!! feature worked great in the old MUI version.

@mbrookes
Copy link
Member

@asrane Looking forward to your pull request.

@tambling
Copy link

Hey @mbrookes I use the fixed header enough and like everything else about 1.0 enough that I'm going to take a stab at this — do you/the Material-UI organization have a preferred way of fixing table headers? The old fixedHeader was great, but I wasn't the biggest fan of how it made all the columns equal width (table-layout: fixed;), so I was going to try to re-implement it to support dynamic column widths.

@mbrookes
Copy link
Member

@tambling That would be great! support for dynamic column widths would be ideal.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 16, 2018

To be noted, the header can be sticky positioned:

// ...

  head: {
    backgroundColor: "#fff",
    position: "sticky",
    top: 0
  }

// ...

        <TableHead>
          <TableRow>
            <TableCell className={classes.head}>

// ...

https://codesandbox.io/s/k0vwm7xpl3

@alexsinfarosa
Copy link

@oliviertassinari Thanks, It works.

@pranayyelugam
Copy link

@oliviertassinari Buttons in the table cell are overlaying the table header. How to resolve it ?
https://codesandbox.io/s/qx24l9vrz6

@mbrookes
Copy link
Member

@pranayyelugam You will need to adjust the zIndex for your buttons.

@pranayyelugam
Copy link

pranayyelugam commented May 18, 2018

@mbrookes What should be the zIndex value for the buttons to appear and function properly ?
Here's the demo
https://codesandbox.io/s/qx24l9vrz6

@donovanclarke
Copy link

@pranayyelugam you can easily set the z-index on the sticky header and it will have the expected result you want.

head: {
    backgroundColor: "#fff",
    position: "sticky",
    top: 0,
    zIndex: 10,
  }

@oliviertassinari
Copy link
Member

For benchmarking purposes: https://vuematerial.io/components/table.

@ryanpcmcquen
Copy link

@oliviertassinari, that won't work on IE 11 though, right? Technically Material UI supports IE 11. Is there a solution that will work with IE 11?

@ryanpcmcquen
Copy link

Does anyone have a solution for fixing the header of a table inside a <Dialog> component? position: sticky is not working.

@maelp
Copy link

maelp commented Sep 7, 2018

Doesn't seem to work on Chrome

@ryanpcmcquen
Copy link

ryanpcmcquen commented Sep 7, 2018

I have a fixed header in this component: https://github.com/SurLaTable/slt-ui/blob/develop/src/ComparisonChart/ComparisonTable/ComparisonTable.js

Material UI 3.x.x!

@koutsenko
Copy link

koutsenko commented Sep 19, 2018

Still no fixed header? IMO its important feature..)

@jlil
Copy link

jlil commented Jan 6, 2019

Bump!

@mhidalgop
Copy link

Any idea about this? I'm using Material Table, but I'm not able to fix the header when the scroll shows up.

@ryanpcmcquen
Copy link

Just use two tables like in my example, @mhidalgop.

@mhidalgop
Copy link

Just use two tables like in my example, @mhidalgop.

Sorry, but it's not work for me :(

@ryanpcmcquen
Copy link

ryanpcmcquen commented Jan 9, 2019

Sorry, but it's not work for me :(

@mhidalgop, mind sharing your example in something like CodeSandbox?

@mhidalgop
Copy link

mhidalgop commented Jan 10, 2019

Finally I have resolved my problem using this solution:

head: {
    backgroundColor: "#fff",
    position: "sticky",
    top: 0,
    zIndex: 10,
  }

Thxs!
:)

@halcwb
Copy link

halcwb commented Feb 20, 2019

To be noted, the header can be sticky positioned:

// ...

  head: {
    backgroundColor: "#fff",
    position: "sticky",
    top: 0
  }

// ...

        <TableHead>
          <TableRow>
            <TableCell className={classes.head}>

// ...

https://codesandbox.io/s/k0vwm7xpl3

This works fine on a desktop browser, however, on mobile browsers it doesn't work.

@mhidalgop
Copy link

To be noted, the header can be sticky positioned:

// ...

  head: {
    backgroundColor: "#fff",
    position: "sticky",
    top: 0
  }

// ...

        <TableHead>
          <TableRow>
            <TableCell className={classes.head}>

// ...

https://codesandbox.io/s/k0vwm7xpl3

This works fine on a desktop browser, however, on mobile browsers it doesn't work.

I'm using this solution in a web app, and in a tablet with Chrome it works fine.

@tiavina-mika
Copy link

the sticky does not work for me, so any other solution on how to fix the table header?

@victorvilaca

This comment has been minimized.

@oliviertassinari oliviertassinari added the priority: important This change can make a difference label Aug 21, 2019
@gsouf
Copy link

gsouf commented Apr 7, 2020

Worked for me when applying this style to the <TableContainer>

    height: 100%;
    overflow-y: auto;

@archfz
Copy link

archfz commented Feb 22, 2022

For anyone else trying to find a good solution that would allow sticky table header over both horizontal and vertical scrolling, I recommend you try: https://github.com/archfz/vh-sticky-table-header

@nichita-pasecinic
Copy link

Hi, couldn't really find any good solution to have a sticky header on Table and a scrollable TableBody ?

The solution proposed by @oliviertassinari

position: "sticky",
top: 0,
zIndex: 100

Does not solve the issue with the scrollable TableBody (scroll container should be the TableBody and do not include the header row, when stickyHeader=true), so why then it is a duplicate of #12014 (comment) ?

@oliviertassinari could you please help and reopen issue #12014 ?

@ryanpcmcquen
Copy link

Hi, couldn't really find any good solution to have a sticky header on Table and a scrollable TableBody ?

The solution proposed by @oliviertassinari

position: "sticky",
top: 0,
zIndex: 100

Does not solve the issue with the scrollable TableBody (scroll container should be the TableBody and do not include the header row, when stickyHeader=true), so why then it is a duplicate of #12014 (comment) ?

@oliviertassinari could you please help and reopen issue #12014 ?

Use two tables:
#6625 (comment)

@nichita-pasecinic
Copy link

nichita-pasecinic commented Jun 26, 2022

@ryanpcmcquen it would mess up the cells alignments, check-out this one - https://codesandbox.io/s/8kw39m1278

@Ashish-21
Copy link

@ryanpcmcquen it would mess up the cells alignments, check-out this one - https://codesandbox.io/s/8kw39

Hi, couldn't really find any good solution to have a sticky header on Table and a scrollable TableBody ?

The solution proposed by @oliviertassinari

position: "sticky",
top: 0,
zIndex: 100

Does not solve the issue with the scrollable TableBody (scroll container should be the TableBody and do not include the header row, when stickyHeader=true), so why then it is a duplicate of #12014 (comment) ?

@oliviertassinari could you please help and reopen issue #12014 ?

You got any work around this?
If yes can you please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: table This is the name of the generic UI component, not the React module! new feature New feature or request priority: important This change can make a difference
Projects
None yet
Development

Successfully merging a pull request may close this issue.