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(from,to) (this works) but I have to sort the
table by hand, which is painfully slow.
Any suggestions?
mscir - 30 Jun 2005 05:39 GMT
> 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
[quoted text clipped - 8 lines]
>
> Any suggestions?
I'd take a look at these:
http://www.mattkruse.com/javascript/sorttable/index.html
http://www.brainjar.com/dhtml/tablesort/demo.html
http://webfx.eae.net/dhtml/sortabletable/demo.html
http://www.kryogenix.org/code/browser/sorttable/
Mike
Martin Honnen - 30 Jun 2005 12:25 GMT
> there doesn't seem to be any way to insert a pre-existing row into a
> table (tBody).
Why not, if you have the tbody element object you can use all the core
DOM methods like appendChild or insertBefore e.g.
tbodyElement.appendChild(rowElement)

Signature
Martin Honnen
http://JavaScript.FAQTs.com/
Gérard Talbot - 30 Jun 2005 16:57 GMT
Martin Honnen wrote :
>> there doesn't seem to be any way to insert a pre-existing row into a
>> table (tBody).
>
> Why not, if you have the tbody element object you can use all the core
> DOM methods like appendChild or insertBefore e.g.
> tbodyElement.appendChild(rowElement)
> there doesn't seem to be any way to insert a pre-existing row into a
table (tBody)
That is my conclusion too. I reported the whole thing to MSIE 7 dev.
team here:
http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerProgrammingBugs
(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