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

Support Fixed Columns? #236

Open
serv opened this issue Oct 22, 2018 · 14 comments
Open

Support Fixed Columns? #236

serv opened this issue Oct 22, 2018 · 14 comments

Comments

@serv
Copy link

serv commented Oct 22, 2018

Is there a support for fixed columns?

Fixed columns are useful when you have a very large horizontally spanning table and you want to have some columns on the left or the right fixed for easier viewing.

It would be awesome if there was a prop for columns like fixed, that takes in a string value of "left" or "right" or null. And have the specified columns be fixed on the left side or the right side.

@gregnb
Copy link
Owner

gregnb commented Oct 22, 2018

Are you watching me? I better check for you in my closet. Hah, all jokes aside I literally just pushed up part one to this. So far it’s enabled for the header itself and I’ll add something for the individual columns. It’ll be an enum property something like

fixed: (‘left’, ‘right’)

@serv
Copy link
Author

serv commented Oct 22, 2018

That's a great news. Closing this issue as it is in progress now. Thanks.

@serv serv closed this as completed Oct 22, 2018
@danielo515
Copy link

Was this implemented ? I didn't saw any reference

@gregnb gregnb reopened this Jan 27, 2019
@saurabh8nitrr
Copy link

Any update on this?

@iamvishalbisht
Copy link

Any update on fixing first column even with createMuiTheme ?

@k3nd477
Copy link

k3nd477 commented May 10, 2019

I'm interested in this functionality too. Updates?

@pellejacobs
Copy link

As a workaround, you can manually set the proper position: sticky css to the table cells and the header. It's not pretty but works:

import { TableCell } from "@material-ui/core";

const style = {
  position: "sticky",
  left: 0,
  background: "white",
  zIndex: 101
};

const columns = [
  {
    name: "Name",
    options: {
      customHeadRender: () => (
        <TableCell key="name" style={{ ...style, top: 0, zIndex: 102 }}>
          Name
        </TableCell>
      ),
      setCellProps: () => ({ style })
    }
  },
  "Title",
  "Location"
];

POC codesandbox for reference: https://codesandbox.io/s/rrr9zw4pwo

@JordanRoth
Copy link

Looks like that works for a single stickied column, but not multiple.

+1 for stickied column functionality.

@krunalsheth3
Copy link

krunalsheth3 commented May 15, 2019

That's a great news. Closing this issue as it is in progress now. Thanks.
Do you know if we got the fixed columns checked in as well ?

@kaydeniz
Copy link

As a workaround, you can manually set the proper position: sticky css to the table cells and the header. It's not pretty but works:

import { TableCell } from "@material-ui/core";

const style = {
  position: "sticky",
  left: 0,
  background: "white",
  zIndex: 101
};

const columns = [
  {
    name: "Name",
    options: {
      customHeadRender: () => (
        <TableCell key="name" style={{ ...style, top: 0, zIndex: 102 }}>
          Name
        </TableCell>
      ),
      setCellProps: () => ({ style })
    }
  },
  "Title",
  "Location"
];

POC codesandbox for reference: https://codesandbox.io/s/rrr9zw4pwo

I implemented this code to my project and it works well, but I want to give different background color for odd and even rows, how can I do that?

@Kadle11
Copy link

Kadle11 commented Sep 17, 2020

Please Refer to #201 for striped rows.

Also for the newer release, setting style is sufficient for fixing the columns.

  setCellProps: () => ({ style: {
             position: "sticky",
             left: 0,
             background: "white",
             zIndex: 101
  }}),
  setCellHeaderProps: () => ({ style: {
              position: "sticky",
              left: 0,
              top: 0, //Incase Header is Fixed
              background: "blue",
              zIndex: 102
  }})

@hew4r
Copy link

hew4r commented Feb 9, 2021

Is there an example of more than one fixed column?

@alextrastero
Copy link

alextrastero commented Mar 3, 2022

Since I've set the width of each "sticky" column I can do this:

    min-width: 200px;

    &:nth-child(1) {
      left: 0;
    }
    &:nth-child(2) {
      left: 200px;
    }
    &:nth-child(3) {
      left: 400px;
    }

Note: this is using emotion/styled

@cristiandaulisio
Copy link

any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests