RowReorder with child row

RowReorder with child row

yelobyelob Posts: 5Questions: 2Answers: 0

I know DT automatically reorders the child row once a parent row is dropped, but has anyone figured out a way to make the row reordering drag both the parent and any children? The UX is confusing when a child row doesn't move with the drag action.

If not, it seems like updating the _clone method of my local copy of datatables.js to look for a child row would take me in the right direction. Any thoughts?

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    I haven't tried it but I wonder if using the RowReorder events might be easier.
    https://datatables.net/reference/event/#rowreorder

    Maybe you could close the child using the pre-row-reorder then reopen using the row-reordered event. Might still be confusing to hide then show the child using these.

    Kevin

  • yelobyelob Posts: 5Questions: 2Answers: 0
    edited September 2018

    Thanks, Kevin, I may try that if I hit a wall. Currently I've updated the _clone method locally to append the childRow (if it exists):

    ...
            var clone = $(dt.table().node().cloneNode(false))
                .addClass('dt-rowReorder-float')
                .append('<tbody/>')
                .append(target.clone(false));
    
            var childRow = dt.row(target).child();
            if (childRow) {
                clone.append(childRow.clone(false));
            }
    ...
    

    That seems to work great to see the child row in the floating element being dragged. Now I just need to figure out where/how the row being dragged is getting hidden in the table and do the same for the child row.

This discussion has been closed.