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

Option to set visible columns #1613

Open
nsallis opened this issue Dec 17, 2020 · 1 comment
Open

Option to set visible columns #1613

nsallis opened this issue Dec 17, 2020 · 1 comment

Comments

@nsallis
Copy link

nsallis commented Dec 17, 2020

There is no option (as far as I can tell) to set the view columns. I would have expected an option like setViewColumns which is the setter, and inverse of onViewColumnsChange. The usecase here is that you cannot currently store the columns the user has selected externally (localstorage or url), and then apply that later without doing the legwork to parse, and check each column when setting display in the column options. Perhaps I am missing something in the docs?

Expected Behavior

There is a prop (in options) that takes an array of column names that are visible by default which internally sets display for each column, over-riding whatever is set by default in the column config.
ex:

<MuiDatatable
columns={[{name: 'age', options: {display: true}}, {name: 'firstName', options: {display: false}}, {name: 'lastName'}]}
options: {
setViewColumns: ['firstName', 'lastName']
}
...
/>

In this case, I would expect to see first name and last name columns and not age. This makes it easy to extract and update user settings externally, and load them again later.

Current Behavior

No such prop/option.

Your Environment

Tech Version
Material-UI 4.11
MUI-datatables 3.4.1
React 16.13.1
browser Chrome 87
@wdh2100
Copy link
Collaborator

wdh2100 commented Dec 18, 2020

@nsallis

Fixed #1581

Upgrade 3.7.3 or display options set string ('true', 'false')

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

No branches or pull requests

2 participants