gregnb / gregnb/mui-datatables

Cannot change view column when there is a change in global state in onViewColumnsChange with setting column option to display.

Open
#1,484 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

When I want to change global state in `onViewColumnsChange` function of options, I cannot change the view column of setting column option to `display: 'true' or 'false'`.

## Expected Behavior

We can change global state in `onViewColumnsChange` using context and change the view column of setting column option to `display: 'true' or 'false'`.

## Current Behavior

When we change global state in `onViewColumnsChange` using context , we cannot change the view column of setting column option to `display: 'true' or 'false'`.

## Steps to Reproduce (for bugs)

Please see codesandbox ( https://codesandbox.io/s/muidatatables-custom-toolbar-forked-q257d )
and change view column in browser.
![aaaa](https://user-images.githubusercontent.com/34390337/90606713-292d3d80-e23b-11ea-8e5a-7ab748a3d9cb.JPG)

We can change "Location" column of not setting option in display, but cannot change "Name" and "Title" columns of setting option in display.

1. make React.createContext object
2. set provider of React.createContext object to React.useState value
3. In child component provided the value, use MUIDatatable and React.useContext and set options to `onViewColumnsChange` and change the context in `onViewColumnsChange` and set column option to `display: "true"` or "display: "false"`.
4. change view column in browser

## Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 4.10.2 |
| MUI-datatables | 3.2.0 |
| React | 16.9.0 |
| browser | chrome |
| etc | |

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked CodeSandbox and reproduce the issue by changing the view columns in the browser. Trace the React context update in onViewColumnsChange and how column options use display for the Name and Title columns. Done means global state changes do not prevent those columns from being shown or hidden.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.