Row grouping and insertAfter

Row grouping and insertAfter

webguruwebguru Posts: 16Questions: 0Answers: 0
edited February 2011 in General
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?

Replies

  • UPEngineerUPEngineer Posts: 93Questions: 0Answers: 1
    Well there is no javascript function in the DOM for insertAfter, only in jQuery.

    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.
  • webguruwebguru Posts: 16Questions: 0Answers: 0
    Thanks for a response UPEngineer , but I had found a solution before reading this.

    [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?
This discussion has been closed.