Setting meta based on physical rows

Tags: #<Tag:0x00007efc65789958>

Hi,

Just wondering if there’s a way to set cell meta using physical row instead of visual? Source code suggests it’s doable but only via metaManager, which is not exposed externally.

Our use case:

  1. User lands on a page with HandsOnTable and 2000 rows of data,
  2. User filters the table, bringing the data down to 100 rows,
  3. User enters some data, which triggers afterChange hook handler,
  4. afterChange hook handler detects clash, trying to mark all clashed rows by adding comment to the first cell of each clashed row,
  5. Part of the clashed rows are visible, comments added, but some rows are invisible due to the applied filter, there’s no way to add comments to them.

All boils down to setting cellMeta using physical row, can anyone please shed some lights on this? Any help will be greatly appreciated!

Cheers,
Charles

edit: Turning the question to a feature request. Would be great to set comment using physical row as well. Currently if one wants to comment on hidden row due to filtering, they can only do that via a hidden column, and when filter/unfilter happened, looping through all visible rows to check if the row needs to have comment added. With large amount of data there’s a lot of unnecessary loops required.

1 Like

Hi

I think in this case you can use toPhysicalRow() method and convert the visual rows this way. I’ve got an example showing one of possible usages of this method. It might be useful in creating your functionality:

https://jsfiddle.net/aszymanski/ge7q9k6h/

Hi Adrian,

Thanks for the reply, but unfortunately this will not work. I’ll expand my use case:

  1. User lands on a page with HandsOnTable and 2000 rows of data,
  2. User filters the table, bringing the data down to 100 rows,
  3. User enters some data in row 1573, which triggers afterChange hook handler,
  4. afterChange hook handler detects clash (the detection runs against the whole data set (2000 rows), not just the filtered one), and pick up physical row numbers [1, 68, 1394, 1573] have clashed.
  5. Among those clashed physical rows, physical row 1 (visual row 1), physical row 68 (visual row 37) are visible, physical row 1394 and physical row 1573 are both hidden due to applied filter.

My logic now needs to make sure physical rows [1, 68, 1394, 1573] are all properly commented with error messages, then when user removes the filter later on, they can see physical rows 1394 and 1573 are both marked as error with comment.

As far as I can see now from the api doc and source code there’s no way to mark physical row 1394 and 1573 as they don’t have visual row number. Invoking hot.toVisualRow(1394) yields null, same as 1573.

Is there any other way to actually tap into metaManager so I comment on physical rows?

Hi @hjbolide

Sorry for keep you waiting. Unfortunately, the rows that are hidden don’t have any kind of index so we can’t convert them in any way. Instead, you can try to give them a flag and basing on it you can attach the comments then.

Hi Adrian,

Yep that’s my current workaround solution, however I’m just thinking if it is possible to deal with physical row for cellMeta at all, scoured the whole source code doesn’t seem like there’s a way.

Do you think I can raise a feature request of this?

Thanks,
Charles

Hi Charles

Ok, I see. Of course, we value input from our users and implement new features basing on the requests.