react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

a way to remove the header from a react-data-grid

Open soma83 opened this issue 9 years ago • 6 comments

Is there a way to remove the header from a react-data-grid?

soma83 avatar Jul 21 '17 20:07 soma83

good question, deserves an answer! I wish I knew, as I want to do so too. Tried <ReactDataGrid headerRowHeight={0} /> but that didn't work ...

andrewlorenz avatar Sep 08 '17 11:09 andrewlorenz

I used the following custom style hack to hide the header.

 .react-grid-Header {
    display:none !important;
  }

  .react-grid-Viewport {
    top: 0px !important;
  }

arogyakoirala avatar Apr 11 '18 03:04 arogyakoirala

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please reopen this if you feel it has been incorrectly closed and we will do our best to look into it. Thank you for your contributions.

stale[bot] avatar Jul 12 '18 11:07 stale[bot]

in the JSX I added a wrapper:

    return (
      <div className = {this.showHeader ? "" : "noHeaderWrapper "} > 
            <ReactDataGrid  />
      </div>
      );

and in external css I used the code from answer from @arkoblog!

.noHeaderWrapper .react-grid-Header {
  display: none !important;
}
.noHeaderWrapper  .react-grid-Viewport {
  top: 0px !important;
}

fierascu avatar Aug 22 '18 07:08 fierascu

I've found challenges with the above solution when adding rows to the react-data-gid on-the-fly. My solution was the following (based off of fierascu's solution:

<ReactDataGrid className='noHeaderWrapper' headerRowHeight={1}  />
.noHeaderWrapper .react-grid-Header {
    display: none;
}

As mentioned thru https://github.com/adazzle/react-data-grid/issues/834:

setting headerRowHeight=0, the height will be considered as undefined and it will use the default row height.

So setting a 1px will get the header as close to 0 as possible, and we can simply hide the header in CSS. The top position doesn't work, unfortunately, as it messes on-the-fly positional calculations of the grid. The above code will likely cause a 1px vertical offset to the grid relative to the page, but due to our repository heavily extending react-data-grid, this was favourable to row content being vertically offset to the top position.

patrickvienneau avatar Jan 31 '22 20:01 patrickvienneau

Seriously? There's no way to have a table w/o a header?

RavenHursT avatar Nov 08 '22 17:11 RavenHursT