Jump to content

Dynamic row addition to table


sajan
 Share

Recommended Posts

Here's a function that removes all children, you can call this function on the table to remove all of the rows in it:

function removeChildren(el){  for (var i = el.childNodes.length - 1; i >= 0; i--)	el.removeChild(el.childNodes[i]);}

As far as building a set of rows, look at the DOM reference on the w3schools site. The functions you will need to use are the document.getElementById function to get a reference to the table, and then the document.createElement function to create the table elements (tbody, tr, td, etc), then the element.appendChild function to add the new elements to the table and maybe document.createTextNode when you want to put text in the cells in the table. There's also a good DOM reference here:http://www.howtocreate.co.uk/tutorials/jav...pt/domstructure

Link to comment
Share on other sites

There might be a memory leak somewhere. Watch the memory that IE is using when you're doing that. If it keeps going up then there's a leak in your code. Theoretically, if you add a bunch of elements and check the memory, then delete all those elements, then add them back again, IE should be using approximately the same amount of memory.

Link to comment
Share on other sites

Open task manager using CTRL-SHIFT-ESC. Click the Processes tab. Go to View -> Select Columns. Make sure Memory Usage, Peak Memory Usage, and Virtual Memory Size are all selected. Watch the memory usage column for iexplore.exe when you're testing. It will be best to not have any other pages open while testing, shut down IE then start it back up again and run your test.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...