gregnb / gregnb/mui-datatables

Option to set visible columns

Open
#1,613 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

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:
```

```
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 |

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the table options handling and the existing onViewColumnsChange flow, then review how column options control display. Done means an options value can restore a selected array of column names and override the configured display defaults, with the behavior covered by the project’s existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.