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

hiddenByColumnsButton should hide in the table but show in the columnsButton selector #21

Closed
peacechen opened this issue Dec 31, 2020 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@peacechen
Copy link
Collaborator

Describe the bug

The prop hiddenByColumnsButton is documented on material-table.com along with the hidden prop. The latter completely removes the columns. They don't render either in the table or in the columnsButton selector. Use case is that some columns should be hidden initially, but selectable if the user chooses to show them.

https://github.com/mbrn/material-table/search?q=hiddenByColumnsButton

To Reproduce
Create a columns array and pass it to material-table. Any of the columns with the field hidden are not visible in the column selector menu that's enabled by options.columnsButton. I hoped that hiddenByColumnsButton would allow them to remain in the menu and hide them in the table, but unfortunately it doesn't have any effect when set in the columns data.

      <MaterialTable
        columns={columns}
        options={{
          columnsButton: true,
        }}
      />
@peacechen peacechen added the bug Something isn't working label Dec 31, 2020
@peacechen
Copy link
Collaborator Author

peacechen commented Dec 31, 2020

Here's how those props work:

hidden: When set, the column does not show in either the table or the columnsButton selector.
hiddenByColumnsButton: This allows the column to show in the columnsButton selector, but it must be set in conjunction with the hidden prop. This has no effect if set by itself.

This is not documented well and isn't intuitive. I propose that we change the behavior so that hiddenByColumnsButton set by itself hides it in the table but shows it in the columnsButton selector. hidden would remain the same and force the column to be removed everywhere (table and columnsButton selector).

Example of how it must be used today:

  const allColumns = [
    {
      title: "My Column",
      hidden: true,
      hiddenByColumnsButton: true,
    },

@oze4
Copy link
Member

oze4 commented Jan 2, 2021

Let me know how I can help!

@peacechen
Copy link
Collaborator Author

I'll work on this as time permits. It's functional so this is a low priority issue. This project needs a detailed list of props like the one at:
https://material-table.com/#/docs/all-props

That's comprehensive but the prop definitions could be improved.

peacechen added a commit to peacechen/material-table-core that referenced this issue Jan 4, 2021
Allows column to be explicitly shown or hidden in columns menu independent of `hidden` flag.
@peacechen
Copy link
Collaborator Author

peacechen commented Jan 4, 2021

I created a PR to address this. See #24 for more details.

I suggest that we add the list of props to the main Readme. It's a hassle hunting for them on separate documentation pages. That will also free up the demo site to focus on examples.

@oze4
Copy link
Member

oze4 commented Jan 4, 2021

@peacechen I agree. We need a better way to keep track of all props.

oze4 added a commit that referenced this issue Jan 7, 2021
@oze4
Copy link
Member

oze4 commented Jan 7, 2021

See here for more #24

@oze4 oze4 closed this as completed Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants