Get initial values of table - Angular

Tags: #<Tag:0x00007efc64bdf8a0>

Hello

I have an issue please .
I have my Angular component. I call the afterChange method to change the color of the cell if I change its value, until this everything is OK.
My need is to get the initial value of cell.
For example: My cell (1,9) contains the value 2 initially, I change the value from 2 to 3. I am going to have a cell background with another color.
If I change the value and set 2 as it was initially I will have the default background.
The initial value of the cell that I can’t get it back
I just want to compare with the initial values to set up the correct cell background color.
Basically, if I reset the initial value I must not have a different color background
My code is as follows:

public afterChangeIndicatorsByRow(changes: any[] | null, source: any): void {

  if (changes != undefined && changes != null && analysis != undefined) {
    changes.forEach(([row, prop, oldValue, newValue]) => {
          if (Number(newValue) < 0) {
            this.hotRegisterer.getInstance(this.id).setCellMeta(row, Number(prop), 'className', this.classNameCells +' error-input');
          } else if (Number(oldValue) != Number(newValue)) { //Here I want to get the init value
            this.hotRegisterer.getInstance(this.id).setCellMeta(row, Number(prop), 'className', this.classNameCells +' success-input');
          }
          else {
            this.hotRegisterer.getInstance(this.id).setCellMeta(row, Number(prop), 'className', this.classNameCells +' default-input');
          }
     
      this.hotRegisterer.getInstance(this.id).render();
    });
  }
}

I’ve already answered the same question on emails, but if someone looking for this as well.

I see two possible ways to get the source data back now

  • make a call to the server that holds a copy of table data
  • parse a stringified data (reopen a deep copy)

Within a month, we should get some more clarity about the sourceData project. Here’s the first commit https://github.com/handsontable/handsontable/pull/6678/files
We are planning to reveal the source data as a deep clone.

It’s ok resolved
Thank you :slight_smile:

Great. I guess that we can close the topic.