Home > OS >  Remove some Specific Cell in Head Column
Remove some Specific Cell in Head Column

Time:03-20

Goal:
Display the column First name, Lastname, age, Visits, Status, Profile progress only. Remove the cell named 'Name' and 'Info'.
Totally, it would be a single row containing 6 column as a head column

Problem:
I'm not used to react-table and how do I do´it?

Codesandbox:
https://codesandbox.io/s/exciting-ganguly-7w2d84

Info:
*newbie in react-table

Thank you!

CodePudding user response:

You just need to change your headings column shape from this

  const columns = React.useMemo(
    () => [
      {
        Header: 'Name',
        columns: [
          {
            Header: 'First Name',
            accessor: 'firstName',
          },
          {
            Header: 'Last Name',
            accessor: 'lastName',
          },
        ],
      },
      {
        Header: 'Info',
        columns: [
          {
            Header: 'Age',
            accessor: 'age',
          },
          {
            Header: 'Visits',
            accessor: 'visits',
          },
          {
            Header: 'Status',
            accessor: 'status',
          },
          {
            Header: 'Profile Progress',
            accessor: 'progress',
          },
        ],
      },
    ],
    []
  )

to this

   const columns = React.useMemo(
    () => [
      {
        Header: "First Name",
        accessor: "firstName"
      },
      {
        Header: "Last Name",
        accessor: "lastName"
      },
      {
        Header: "Age",
        accessor: "age"
      },
      {
        Header: "Visits",
        accessor: "visits"
      },
      {
        Header: "Status",
        accessor: "status"
      },
      {
        Header: "Profile Progress",
        accessor: "progress"
      }
    ],
    []
  );
  • Related