Row grouping and insertAfter
Row grouping and insertAfter
I'm following the row grouping example: http://www.datatables.net/examples/advanced_init/row_grouping.html
I have a special use case where I want the group name row to appear AFTER the the actual rows.
So I need:
[code]nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );[/code]
to be this:
[code]nTrs[i].parentNode.insertAfter( nGroup, nTrs[i] );[/code]
This only shoots off errors. So I'm assuming that "insertBefore" as used in the example is not the traditional one found in jquery? If it was, I would imaging insertAfter would work as well.
Anyways... how would I go about doing this?
I have a special use case where I want the group name row to appear AFTER the the actual rows.
So I need:
[code]nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );[/code]
to be this:
[code]nTrs[i].parentNode.insertAfter( nGroup, nTrs[i] );[/code]
This only shoots off errors. So I'm assuming that "insertBefore" as used in the example is not the traditional one found in jquery? If it was, I would imaging insertAfter would work as well.
Anyways... how would I go about doing this?
This discussion has been closed.
Replies
However, I have done this before and it may or may not work in your particular situation.
Try adding the .nextSibling to the end of your statement like this:
Change this:
[code]
nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
[/code]
to this:
[code]
nTrs[i].parentNode.insertBefore( nGroup, nTrs[i].nextSibling );
[/code]
Your mileage may vary.
[code]$(nTrs[i]).after(''+sGroup+'');
[/code]
It works perfectly. Is there anything wrong with this approach or is it more or less the same thing as the code you posted?