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

ReactDataGrid width not respecting container padding

Open ZephD opened this issue 9 years ago • 7 comments

I have a bootstrap Grid -> Row -> Col, with my ReactDataGrid inside.

The ReactDataGrid is larger than the column width by the sum of the padding on the sides.

Calls to .updateMetrics() do not fix the issue.

Probably due to using box-sizing: border-box in the css.

Here you can see the grid overflowing it's container: screenshot from 2017-02-14 15-59-07

Here is the container (bootstrap col). Notice the overflow is the sum of the side padding (green) screenshot from 2017-02-14 15-58-51

ZephD avatar Feb 14 '17 16:02 ZephD

Workaround: Wrap the ReactDataGrid in a div: <div><ReactDataGrid /></div> (the new div does not have padding, but fills the bootstrap column)

ZephD avatar Feb 14 '17 16:02 ZephD

Wrapping ReactDataGrid inside another div doesn't seem to help `

    <div className="col-md-12">
      <div>
        <ReactDataGrid
          columns={columns}
          rowGetter={rowGetter}
          rowsCount={rows.length}
          minHeight={375}/>
      </div>
    </div>
  </div>

`

vijayrajaram avatar Feb 17 '17 20:02 vijayrajaram

Addition div gives no results, calling updateMetrics() after some time (not 0) makes grid to stay inside container. But then we got flickering effect because grid is resizing itself during init. This error exist even on demo page of this grid. Calculation is valid after first resize when the updateMetrics is called.

jsobus-neurosys avatar Sep 15 '17 10:09 jsobus-neurosys

@jsobus-neurosys Try to wrap grid in absolute positioned full-width div, see: https://github.com/adazzle/react-data-grid/issues/295#issuecomment-332212132

lavor avatar Sep 26 '17 14:09 lavor

@lavor Good idea but in my case still the same. Calculation is done wrong for the first time, and need to resize widow to make it look well. My view is complex one with many dynamic items which makes me calling updateMetrics very often because grid itself is not updating its layout.

jsobus-neurosys avatar Oct 02 '17 07:10 jsobus-neurosys

I found something, all sizing is ok now, problem was then the main container got its own scroll. I mean this scroll appears dynamically after grid is loaded. Problem was that scroll showing/hidding is not calling resize event. The fix for this can be done using that sham: https://gist.github.com/AdamMcCormick/d5f718d2e9569acdf7def25e8266bb2a

jsobus-neurosys avatar Nov 08 '17 10:11 jsobus-neurosys

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 13:07 stale[bot]