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

Custom Renderer Messing Up Scrolling

Open nickswope opened this issue 9 years ago • 14 comments

HAVE YOU ALREADY SEARCHED FOR SIMILAR ISSUES? PLEASE HELP US OUT AND DOUBLE-CHECK FIRST!

didn't see anything

ALSO, PLEASE DON'T BE THAT PERSON WHO DELETES THIS TEMPLATE. IT'S HERE FOR A REASON.

THANKS!

WHICH VERSION OF REACT ARE YOU USING?

Officially Supported:
[ ] v0.14.x
Community Supported:
[ x] v15.0.x

WHICH BROWSER ARE YOU USING?

Officially Supported:
[ ] IE 9 / IE 10 / IE 11
[ ] Edge
[ x] Chrome
Should work:
[ x] Firefox
[ x] Safari

I'm submitting a ... (check one with "x")

[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/adazzle/react-data-grid/blob/master/CONTRIBUTING.md

Current behavior When adding stuff other than a simple <div><Row /><div> as a custom row renderer, the scroll functionality stops working well.

Expected/desired behavior Smooth scrolling no matter what is provided as the custom renderer

Reproduction of the problem If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem.

https://jsfiddle.net/nswope/a8avjpmc/

That's an example, and you can see how the scrolling becomes very choppy when the <h3> is added as a sibling of the <Row />. When it gets to the bottom it starts glitching really badly. This example is almost usable, but in my project this behavior is much worse.

What is the expected behavior? Smooth scrolling, just like if you comment out the <h3>

What is the motivation / use case for changing the behavior?

Trying to make expandable rows like this:

image

nickswope avatar Apr 06 '17 21:04 nickswope

I am facing the same problem with a custom row component. It seems like the viewport height is not getting updated when the row height is changed. This in turns throw off scrolling. Have you found a solution to this issue?

alwasa0b avatar Sep 14 '17 14:09 alwasa0b

No I haven't. Because I never got so much as an acknowledgement about this issue, and there's a backlog of over 200 issues, I decided this project is probably a good one to stay away from. I jumped to ag-Grid

nickswope avatar Sep 14 '17 14:09 nickswope

This is a major issue for us. Perhaps we can generate some concern in this direction? Thanks for the tip on ag-Grid, but pricing is never fun. Would really like to see some improvement in this neighborhood.

nathanielmoon avatar Feb 06 '18 00:02 nathanielmoon

I have not used rowRenderer this way but seems like ReactDataGrid.Row height is different from the custom rowRenderer height which is somehow breaking scrolling. I have created an example to fix the flickering, this seems a bit hacky but this particular case requires some investigation. We will be happy to accept a PR which can make rowRenderer more flexible

https://codesandbox.io/s/rjw20ynoqp

Made 3 changes

// Custom renderer
getRowStyle() {
    return {
      color: this.getRowBackground(),
      height: this.props.height // New prop
    };
},

render: function () {
    return (
      <div style={this.getRowStyle()}>
        <ReactDataGrid.Row ref="row" {...this.props} height={ReactDataGrid.Row.defaultProps.height} /> // Set default height
        <h3>I go between rows</h3>
      </div>
    );
  }

// Grid
render() {
    return (
      <ReactDataGrid
        columns={this._columns}
        rowGetter={this.rowGetter}
        rowsCount={this._rows.length}
        minHeight={500}
        headerRowHeight={35}
        rowHeight={100} // Provide explicit height, this should match the rowRenderer height
        rowRenderer={RowRenderer} />);
  }


There is an open ticket to improve performance in general and it should address laggy scrolling as well

amanmahajan7 avatar Feb 09 '18 23:02 amanmahajan7

@amanmahajan7 Any update here?

srikanthpavuluri avatar Apr 23 '18 11:04 srikanthpavuluri

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]

I am having this same issue when trying to render tables within rows.

Austint30 avatar Mar 07 '19 16:03 Austint30

Any update on this? The flicker happens even on the sample at https://adazzle.github.io/react-data-grid/docs/examples/row-renderer

scottdurow avatar May 14 '19 17:05 scottdurow

The lag is really bad when you start rendering tables within rows. @amanmahajan7 some update would be really appreciated.

Thiyageshv avatar May 14 '19 22:05 Thiyageshv

@Austint30 were you able to solve the flickering?

Thiyageshv avatar May 14 '19 23:05 Thiyageshv

No. I gave up rendering another table within a row. I decided to put links in each row cell that shows the nested table in a separate page.

It seems that rendering elements that stretch the row height cause odd scrolling behavior.

Austint30 avatar May 15 '19 05:05 Austint30

I opened a new issue for this, since this one was closed, #1670

JSoet avatar May 28 '19 09:05 JSoet

Actually guys this is super easy to fix. All you have to do is make sure your rowrenderer matches how your ReactDatagrid rows height are shown below:

RowRenderer = ({ renderBaseRow, ...props }) => {
const color = props.row.status.includes("Passed") ? 'lightgreen' : props.row.status.includes("Failed") ? 'orange' : 'lightgrey' const bord = this.state.sessionIDfilter === props.row.id ? '5px solid #66afe9' : 'none'

dom = <div onClick={() => this.setSessionFiltertoRowClicked(props.row.id)} style={{ cursor: 'pointer', border: bord, background: color }}>{renderBaseRow({ ...props,height: 500 //THIS HAS TO MATCH })}

;

} } return dom; };

<ReactDataGrid rowHeight={500} //THIS ONE HAS TO MATCH THE ONE IN ROWRENDERER headerRowHeight={50} columns={columns} rowGetter={i => filteredRows[i]} rowsCount={filteredRows.length} rowRenderer={this.RowRenderer} toolbar={} onAddFilter={(filter) => this.handleSessionFilterChange(filter)} onClearFilters={() => this.setState({ setSessionFilters: {} })} getValidFilterValues={columnKey => this.getValidFilterValues(rows, columnKey)} getCellActions={this.getCellActions}

/>

sammysamx20 avatar May 29 '19 16:05 sammysamx20

Unfortunately that's not an option in our case because we wanted it to have a dynamic row height... but good find! 👍

JSoet avatar May 30 '19 14:05 JSoet