Insert row into tBody

V

Vic Sowers

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?
 
M

mscir

Vic said:
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?

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
 
M

Martin Honnen

Vic Sowers 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)
 
G

Gérard Talbot

Martin Honnen wrote :
Vic Sowers wrote:




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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,316
Latest member
naturesElixirCBDGummies

Latest Threads

Top