Insert row into tBody

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vic Sowers

    #1

    Insert row into tBody

    I'm trying to sort an HTML table (tBody) on one of its columns dynamically.
    My approach is to remove all the rows into an array, sort the array, and
    insert to rows back into the tBody.

    But, there doesn't seem to be any way to insert a pre-existing row into a
    table (tBody). I've tried inserting a blank row and replacing it with the
    saved row, but this fails as well.

    I know about tBody.moveRow(f rom,to) (this works) but I have to sort the
    table by hand, which is painfully slow.

    Any suggestions?


  • mscir

    #2
    Re: Insert row into tBody

    Vic Sowers wrote:[color=blue]
    > I'm trying to sort an HTML table (tBody) on one of its columns dynamically.
    > My approach is to remove all the rows into an array, sort the array, and
    > insert to rows back into the tBody.
    >
    > But, there doesn't seem to be any way to insert a pre-existing row into a
    > table (tBody). I've tried inserting a blank row and replacing it with the
    > saved row, but this fails as well.
    >
    > I know about tBody.moveRow(f rom,to) (this works) but I have to sort the
    > table by hand, which is painfully slow.
    >
    > Any suggestions?[/color]

    I'd take a look at these:






    Mike

    Comment

    • Martin Honnen

      #3
      Re: Insert row into tBody



      Vic Sowers wrote:

      [color=blue]
      > there doesn't seem to be any way to insert a pre-existing row into a
      > table (tBody).[/color]

      Why not, if you have the tbody element object you can use all the core
      DOM methods like appendChild or insertBefore e.g.
      tbodyElement.ap pendChild(rowEl ement)

      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      • Gérard Talbot

        #4
        Re: Insert row into tBody

        Martin Honnen wrote :[color=blue]
        >
        >
        > Vic Sowers wrote:
        >
        > [color=green]
        >> there doesn't seem to be any way to insert a pre-existing row into a
        >> table (tBody). [/color]
        >
        >
        > Why not, if you have the tbody element object you can use all the core
        > DOM methods like appendChild or insertBefore e.g.
        > tbodyElement.ap pendChild(rowEl ement)
        > [/color]
        [color=blue]
        > there doesn't seem to be any way to insert a pre-existing row into a[/color]
        table (tBody)

        That is my conclusion too. I reported the whole thing to MSIE 7 dev.
        team here:

        Browse thousands of hours of video content from Microsoft. On-demand video, certification prep, past Microsoft events, and recurring series.

        (See Other (Non-FORM) Elements issues section)

        insertRow does not work like it should in MSIE 6. Of course, appendChild
        is a workaround.

        Gérard
        --
        remove blah to email me

        Comment

        Working...