After re render old data is shown

Tags: #<Tag:0x00007f8b19d9bee8>

Hi,

I have created a table with Handsontable which automatically updates the data of the underlying database when the value of a cell is changed. The table is too width and too long for the screen, so to see the rest of the table, the user needs to scroll left/down. But doing that the table is re rendered and the original data is shown. I can solve that by loading the data every time a change have been saved to the database or before the table is re rendered, but this slows down. I don’t understand why this is needed and is there a way to achieve this without loading the data again?

With regards,

Paul Poels

Hi Paul,

If you do not want to rerender the table you can expand the offset. It makes the initialization loading a bit longer but it works well afterwards.
https://handsontable.com/docs/6.1.1/Options.html#viewportColumnRenderingOffset
https://handsontable.com/docs/6.1.1/Options.html#viewportRowRenderingOffset

Hi,

Thanks for you answer, but i do not have problems with the fact that the table re renders. The point is that re render will load the original data, not the changed data. So the table loads a local copy of the data when re rendering and this is not updated when the data in the table is changed. Is there a way to update the local data copy without reloading it from the server.

With regards,

Paul Poels

Usually renderer do not change data when it is reloaded. You need to have some kind of logic that refers to the old dataset, but I won’t be able to help without a demo where this case can be replicable.

Hi,

Maybe I was not clear, but I think you don’t understand my problem. I will try to explain it again.

  • A table is loaded with data from a database.
  • A field is changed, data is saved to the database.
  • When the table re renders the old value is shown, not the new changed value.

My question is, why is the old value shown and not the changed value. And is there a way (without reloading the data from the database) to achieve this.

Of course when i reload the data from the database, the new value is shown. But reloading the data slows down the system.

With regards,

Paul Poels

I would need to see what you are doing in the afterChange hook as I believe you use one. Here https://jsfiddle.net/t6wuhqLo/ is a simple example when I do some action that interrupts saving the cell but after user closes the alert the value is saved.

Hi,

In you’re example I saw that the afterChange was placed inside the definition of the table. In my situation I had placed it in an updateSettings hook. I moved it to the table definition and now it works as I expected.

Thanks for you’re help.

With regards,

Paul Poels

Great! Thank you for the update. I’m glad it works now.