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

[data grid] The user should not hide all columns; at least one column should be displayed #13328

Open
vadaviya638 opened this issue May 31, 2024 · 7 comments
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Column visibility

Comments

@vadaviya638
Copy link

vadaviya638 commented May 31, 2024

Steps to reproduce

No response

Current behavior

  • When the user clicks on the 'Hide Column' option, the table becomes blank, and the user cannot see any data. If the user wants to view or modify the table data, they need to refresh the page, after which the table data will be displayed
screen-capture.48.webm
  • you already did in other props , i mention below
screen-capture.49.webm

Expected behavior

at least one column display

Context

No response

Your environment

No response

Search keywords: datagrid

@vadaviya638 vadaviya638 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 31, 2024
@michelengelen michelengelen added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Column visibility and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 31, 2024
@michelengelen michelengelen changed the title [DataGrid] : The user should not hide all columns; at least one column should be displayed [data grid] The user should not hide all columns; at least one column should be displayed May 31, 2024
@michelengelen
Copy link
Member

Thanks @vadaviya638 for opening an issue for this problem.
I could confirm that the grid will enter a state where the user has no means to show columns again, so I would consider this a bug.

I'll add this to the board!

@mparsakia
Copy link

Hi @michelengelen, thanks for updating this issue. Is there a guide on extending or overriding the behavior of the built-in MUI Columns Menu we can use as a workaround for now? Ideally we could clone the built-in one MUI uses and just add some custom logic.

@michelengelen
Copy link
Member

Hey @mparsakia
This example code would enable you to build your custom columns management panel:

import * as React from 'react';
import { DataGrid, GridPanelWrapper, GridSlots } from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

const CustomColumnsPanel: GridSlots['columnsPanel'] = (props) => {
  console.log(props);
  return <GridPanelWrapper {...props}>COLUMNS MANAGEMENT</GridPanelWrapper>;
};

export default function CustomToolbarGrid() {
  const { data } = useDemoData({
    dataSet: 'Commodity',
    rowLength: 10,
    maxColumns: 6,
  });

  return (
    <div style={{ height: 400, width: '100%' }}>
      <DataGrid
        {...data}
        slots={{
          columnsPanel: CustomColumnsPanel,
        }}
      />
    </div>
  );
}

But this would mean a ton of custom implementation.
For access to the gridApi you would need to add to the custom component:

const apiRef = useGridApiContext();

@mparsakia
Copy link

Would be a way to just import (or clone) and modify the existing MUI Columns menu while we wait on a fix? If possible, it shouldn't be too hard to shoe in some checks if trying to hide the last existing column.

@michelengelen
Copy link
Member

As mentioned in #14395 it would be a good idea to show an overlay like we do for having no rows.

@mm105
Copy link

mm105 commented Nov 27, 2024

any updates regarding this issue?

@manumena
Copy link

Is there some docs where we can see how the GridPanelWrapper should be created and what should it contain? I can make a list of column names with checkboxes but how would they interact with the DataGrid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Column visibility
Projects
Status: 🆕 Needs refinement
Development

No branches or pull requests

5 participants