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

[docs] Remove column id anywhere its not displayed #346

Closed
oliviertassinari opened this issue Sep 24, 2020 · 4 comments · Fixed by #355
Closed

[docs] Remove column id anywhere its not displayed #346

oliviertassinari opened this issue Sep 24, 2020 · 4 comments · Fixed by #355
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 24, 2020

Based on #342, we can simplify the demos of the documentation to not include the ID column if displayed hidden.

const columns: ColDef[] = [
- { field: 'id', hidden: true },
  { field: 'firstName', headerName: 'First name', width: 130 },
  { field: 'lastName', headerName: 'Last name', width: 130 },

For instance on the https://material-ui.com/components/data-grid/rendering/ page:

/~https://github.com/mui-org/material-ui-x/blob/6d23e1afb344d783727c484a41b5a8e1fd2cb5e1/docs/src/pages/components/data-grid/rendering/ValueGetterGrid.tsx#L5

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation component: data grid This is the name of the generic UI component, not the React module! labels Sep 24, 2020
@oliviertassinari oliviertassinari changed the title [docs] Rename column id anywhere its not used. [docs] Remove column id anywhere its not used. Sep 24, 2020
@oliviertassinari oliviertassinari changed the title [docs] Remove column id anywhere its not used. [docs] Remove column id anywhere its not displayed Sep 24, 2020
@kodeschooler
Copy link

kodeschooler commented Jan 28, 2022

Not sure if this is the same issue, but I have my ID field configured like this:

         {
            field: "Id",
            hide: true,
            hideable: false,
            filterable: false,
          }

And when you go to "Show Columns" (on any column header) it displays the ID in the Show All / Hide All menu with the switch disabled. But how do we not show it at all? The ID is required by the grid so we had to use it, but we don't want it to be displayed anywhere as it has no meaning to a user. Can this be done?

@m4theushw
Copy link
Member

@kodeschooler Could you open another issue? This one was only to hide the ID column in our demos. Regarding not displaying hideable=false columns in the filter painel, I asked about that in #3433 (comment). Maybe we need to add another option to configure the behavior.

@kodeschooler
Copy link

Ah. I will, sure, but now I'm a little more confused. I thought an ID column was required for the grid. Then I looked at the demos where you guys have an ID in the row data but don't have an ID column defined in the columns. So I just commented out my ID column and it doesn't throw an error about a missing ID. And, it actually produces the result I want- which is to not have ID show in the hide/show menu (because I'm not displaying it).

Is ID only required in the rows data, but not in the columns? Or is it not required in either? Maybe I'm confusing it with something else and ID is not in fact required. If that's the case I don't really have an issue. I thought at one point recently I got an error about it missing.

As far as not displaying hideable=false columns in filter panel, they don't. I just checked.

@m4theushw
Copy link
Member

It's not necessary to have an "ID" column in the columns prop. The only requirement is to have an id field in each row object or define getRowId.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants