Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I keep header with no data in DataTable from react-data-table-component?

My goal is to have the table head whether or not there is data, but I also don’t want a noDataComponent, because the idea I want to execute requires there to be none. I can’t seem to find any information online about preventing the head from going away when there is no data, only other components that do that natively.

  <DataTable
      columns={columns}
      data={data}
      actions={actions}
      progressPending={loading}
      noDataComponent={<></>}
  />

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Simply set persistTableHead to true.

<DataTable
      columns={columns}
      data={data}
      actions={actions}
      progressPending={loading}
      persistTableHead={true}
/>

Description from the doc:

persistTableHead: Show the table head (columns) even when progressPending is true. Note: The noTableHead will always hide the table head (columns) even when using persistTableHead

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading