Nested table Structure

Tags: #<Tag:0x00007efc65684620> #<Tag:0x00007efc656844e0>

I have a few questions regarding the nested table feature of Handsontable; I tried to search for solutions but I am just running in circles, any reference or solution would help.

I have a very simple nested table with parent and children, now what I am looking for is:

  1. Independent indexing for the children (at least on the UI part if not the code part)
  2. A hook I can call in the code instead of having to rely on the context menu to add child rows by referencing a/the parent

Adding a image of what I am working with for reference:
hot%20feat

NOTE: if it is a duplicated question, please reference it and feel free to close this

Hi @param556

the API is not complex for the nestedRows plugin. However, you can also rely on the fact that the parent and child have different classNames, here’s an example https://jsfiddle.net/handsoncode/qj6p3kzn/

Here’s an idea to track collapsing/expanding of rows https://jsfiddle.net/doeft8r2/7/.

I hope it helps.

Hi! @aleksandra_budnik
Maybe I wasn’t able to explain it better, you see the thing I am looking for is a way to add new child rows to a parent without using the context menu.

Something like hot.addChildRow(parent, element, index)

[addChildRow is just my lingo, I searched the documentation for something like this but could not find any] This would essentially add a child row upon clicking of the plus button as I have in the image in the question

As for the indexing, I meant something like ↓ this on the frontend only, nothing to do with the data
[uploading as image because markdown isnt letting me show what i want to]
image

There is no official API to do it. Underneath, we use index mapper to do it https://github.com/handsontable/handsontable/blob/c8116f8f14dad966b729486549bae5db247bc476/handsontable/src/plugins/nestedRows/data/dataManager.js#L473

The only way is to call alter() as for a regular row addition.

In general rowIndexMapper holds a lof of information about the indexes of rows. I highly recommend checking it at https://handsontable.com/docs/javascript-data-grid/api/index-mapper/

1 Like

@aleksandra_budnik
Ah snap!
Thank you for letting me know about the index mapper though, I will beep around and find out if I can make do with something from the reference you provided.

Also, please do let me know if you guys plan to put an API of this kind on your roadmap, it would be helpful I feel.

Not at the moment. But I will update you if that changes.

1 Like