2

How to remove a column from column chooser in the devextreme-reactive react grid? Please note that I do not want to disable the column in the column chooser.

I am using the following grids: https://devexpress.github.io/devextreme-reactive/react/grid/docs/guides/column-visibility/

There is the documentation for columnChooserItem But I don't know how to use it. https://devexpress.github.io/devextreme-reactive/react/grid/docs/reference/column-chooser/#columnchooseritem

You can try the code over here: https://codesandbox.io/s/f1ogw

import React, { useState } from 'react';
import Paper from '@material-ui/core/Paper';
import {
  Grid,
  Table,
  TableHeaderRow,
  ColumnChooser,
  TableColumnVisibility,
  Toolbar,
} from '@devexpress/dx-react-grid-material-ui';


import { generateRows } from '../../../demo-data/generator';

export default () => {
  const [columns] = useState([
    { name: 'name', title: 'Name' },
    { name: 'gender', title: 'Gender' },
    { name: 'city', title: 'City' },
    { name: 'car', title: 'Car' },
  ]);
  const [rows] = useState(generateRows({ length: 6 }));
  const [defaultHiddenColumnNames] = useState(['gender', 'car']);
  const [tableColumnVisibilityColumnExtensions] = useState([
    { columnName: 'city', togglingEnabled: false },
  ]);

  return (
    <Paper>
      <Grid
        rows={rows}
        columns={columns}
      >
        <Table />
        <TableHeaderRow />
        <TableColumnVisibility
          defaultHiddenColumnNames={defaultHiddenColumnNames}
          columnExtensions={tableColumnVisibilityColumnExtensions}
        />
        <Toolbar />
        <ColumnChooser />
      </Grid>
    </Paper>
  );
};
Jaskaran Singh
  • 2,392
  • 24
  • 39
  • I got this link where the documentation is given for the column chooser component. https://devexpress.github.io/devextreme-reactive/react/grid/docs/reference/column-chooser/ It would be great if anybody can tell how to use these interfaces. – Jaskaran Singh Apr 30 '20 at 12:01
  • There is the documentation for columnChooserItem But I don't know how to use it. https://devexpress.github.io/devextreme-reactive/react/grid/docs/reference/column-chooser/#columnchooseritem – Jaskaran Singh Apr 30 '20 at 12:11

1 Answers1

0

By using showInColumnChooser

For the columns that you dont want to appear in the column chooser, just set this to false

You can test in the demo

<Column allowHiding={false} dataField="Full_Name" showInColumnChooser={false}/>

boonboon
  • 21
  • 2