Set custom index for nested Rows

Tags: #<Tag:0x00007efc64974048>

Hi,
I want to implement nested rows in my application. My requirement is,

All the cells in the parent row should be editable. So I need to get the row index and column index in the afterChange listener to update my reference object.
Also all the child rows should be read only and need to have a different color.

When I try to implement this, The parent row and child rows index are changing when ever I expand and collapse the child. Because of this I couldn’t set the read only exactly to child rows.
Also when I edit the parent row cells while the child is in expand mode, I am getting different index.
How to get the fixed row index for parent and child in both the expand and collapse mode. Also do we have any option to set the custom index for my case?

Will the IndexMapper resolve this issue? Can you please give me sample code for this if any?

Hi @ramprasath.raja

We do not have an official method on how to get indexes to parents and children. So I propose something like this http://jsfiddle.net/handsoncode/38qzwo0d/
Styles for parents are overwritten via CSS but you can also use the IF condition I’ve added in the cells method to attach a className.

@aleksandra_budnik Thanks for your reply.
As per your sample I can get the child using the specified class name and make that as readOnly mode.
But how could I get the stable row index for all the parent cells? It keeps on changing when we expand and collapse any children. Based on the Row index I need to get my reference object and update it.

It keeps on changing when we expand and collapse any children.

That is done by the design.
That is why I propose to get an index of a cell with the appropriate className 'ht_nestingParent' (line 117 in my demo)

@aleksandra_budnik I think I didn’t get the answer. Let me rephrase the question.
We can use this class name to set any config for this row. That I got it.
But my second question is, As I mentioned earlier we are allowing edit for parent row cells.
Currently I am using “afterChange” listener to get the edited cell’s value and it’s row index and column index. Based on these index I can update the reference object.
But When I do the cell edit ( parent row cell) while the child is in expand mode. I am getting different row index from afterChange listener.

I used to get actual index using “toPhysicalRow()” method. But this output is also changing when I add any child dynamically.

Will any methods in the IndexMapper resolve this?

IndexMappers give you a map of the indexes.

Maybe I’ll be able to share some tips if you could share a demo with your recent implementation of the afterChange. Would that be possible?

Hi @aleksandra_budnik,

I have added sample code here. By default if we edit the cells from the last 3 rows, we are getting a physical row index. Incase if we add any child by clicking first 4 rows and then try to edit the last 3 rows then the physical row index is also changing.
http://jsfiddle.net/ramprasath_raja/qb2x3nc9/65/

Can you give any solution to add child with out changing the index?

If rows are added the index has to change. The afterChange does not differ if that’s a child or a parent row. Maybe you can attach unique cell metadata to those cells and then track that data. Here https://jsfiddle.net/handsoncode/tb7rw0xk/ is an example of adding custom cell metadata.