ag-grid / ag-grid

The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
http://www.ag-grid.com
Other
12.57k stars 1.85k forks source link

Redrawing fails when updating data #6776

Closed marlokessler closed 1 year ago

marlokessler commented 1 year ago

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

[x] bug report => see 'Providing a Reproducible Scenario'
[] feature request => do not use Github for feature requests, see 'Customers of AG Grid'
[] support request => see 'Requesting Community Support'

Providing a Reproducible Scenario We use ag-grid-vue and pass custom cell renderers for each column which should have one like this:

column.cellRenderer = defineComponent({
    props: ["params"],
    render() {
      return h(
        "span",
        { class: "ag-custom-cell-content" },
        slots[`item.${column.field}`]{
          item: this.$props.params.data,
        })
      );
    },
  });

Now to the actual bug reproduction: In one table, we use this to render a "delete" button. When clicking the button, the respective item is deleted from the row-data array and the table gets updated. Nevertheless this only happens once, when clicking the delete button in another row, the table does not redraw again. Then, when setting the row-data to the original array (i.e. "resetting" the data), I get the following error.

Current behavior It seems to be a redrawing issue:

Error: AG Grid: cannot get grid to draw rows when it is in the middle of drawing rows. Your code probably called a grid API method while the grid was in the render stage. To overcome this, put the API call into a timeout, e.g. instead of api.redrawRows(), call setTimeout(function() { api.redrawRows(); }, 0). To see what part of your code that caused the refresh check this stacktrace.
    at RowRenderer2.getLockOnRefresh (ag-grid-community.auto.esm.js:36619:19)
    at RowRenderer2.redrawAfterModelUpdate (ag-grid-community.auto.esm.js:36567:14)
    at RowRenderer2.onPageLoaded (ag-grid-community.auto.esm.js:36470:14)
    at ag-grid-community.auto.esm.js:1052:17
    at Set.forEach (<anonymous>)
    at processEventListeners (ag-grid-community.auto.esm.js:1047:77)
    at EventService2.dispatchToListeners (ag-grid-community.auto.esm.js:1057:13)
    at EventService2.dispatchEvent (ag-grid-community.auto.esm.js:1028:14)
    at PaginationProxy2.onModelUpdated (ag-grid-community.auto.esm.js:38164:27)
    at ag-grid-community.auto.esm.js:1052:17

Expected behavior It should rerender correctly.

Please tell us about your environment: macOS 13.4

kiril-matev commented 1 year ago

Hello @marlokessler,

Thank you for reporting this.

We're keen to look into this but we can't start because you've not provided a live example reproducing the issue.

Please send us a live plunker sample which shows the issue.

We're looking forward to your response.

makis-x commented 1 year ago

These redraw errors are so evil cause their almost impossible to trace and when you have 50k lines of code creating a plunker is impossible. This is the biggest issue were facing at my company now and what I see as the biggest threat to AgGrid's world domination. Just my 2 cents

AG-Zoheil commented 1 year ago

Hi @makis-x,

Thank you for submitting this on Github.

Whilst world domination does sound very enticing, being able to reproduce bugs is an invaluable first step to attempting to fix them (as I'm sure you know/agree).

If you can provide a plunker or even a sample repo we can download and run, we can attempt to tackle this problem.

As this issue has been open without any further interaction for a while, I will be closing it.

If it has already been resolved by other means, you can ignore this. If however, you are still in need of support and have some more information you can provide or even the elusive reproducible scenario (a man can dream), please do let us know and we can look at re-opening it.

Kind regards, Zoheil