Way to have row's reference in cellMeta

Tags: #<Tag:0x00007efc6d3d2960>

Hi,
We have a table where adding, removing, copying and pasting actions are implemented. We save whole records into DB when the save button is clicked and we also save when record is copied and pasted on to the table.

To Save and Update into DB, we need to maintain a unique ID for each rows. Here we have used cell property to store the ID references which are like this
[{row: 0, col: 1, row_id: 100}, {row: 1, col: 1, row_id: 101}]

The problem could be when the filter is applied, the filtered records are shown (which changes the indexes of the rows), right?

Assume, I have 3 rows for which I have 3 references in cell array when I apply a filter for last 2 records not the first one, now it would display except first record other 2 records.

Now the filtered records are replaced with existing records so it changes the row indexes (like the second row’s record becomes the first row and third row’s record becomes the second row,
now the references we maintained is not correct in cell property) right?
How can we overcome from this?

Or is not good way to store the row’s reference in cell property? Is there any other way to fix this?

Please help me solve this.
Thanks in advance!

Hey @subashdbc

Have you hidden the column with row_id? You may also consider using a cell meta setCellMeta() (docs: https://handsontable.com/docs/7.1.1/Core.html#setCellMeta).
It is added per cell but doesn’t take place in the data and its processes (filtering, sorting, edition).

Thanks for the reply,
I don’t hide any columns in the table. row_id is just a reference property I have added in the cell array to identify unique rows.

Even though using setCellMeta row’s indexes are getting changed?
Is there any/good way to store row properties?

Can you please suggest?

Unfortunately, we do not have a dedicated method for rows. You can, however, pass all the properties via cells methods. Example https://jsfiddle.net/handsoncode/ku564jcx/

Yeah we can pass properties in cells I have also tried it,

but this is the problem

When filtering the indexes of the rows are changing, so we couldn’t get the exact property of row
Could you suggest any solution?

This is a matter of using physical and visual indexes. Once you do one of those operations

  • moving
  • sorting
  • filtering
  • nesting

visual indexes of rows change.

However, physical indexes never change. To get physical indexes you can call these two methods

I never know the concept of visual indexes and physical indexes
Thanks :slight_smile:

Without the generic (physical) indexes after doing multiple movements, sorting etc. we won’t be able to tell what was the basic state of the table.
However, as this is also useful for the developers we’ve added the convertion methods to the public API.