Memory issue while using event for row selection

Memory issue while using event for row selection

sdinesh21sdinesh21 Posts: 37Questions: 0Answers: 0
edited May 2013 in DataTables 1.9
Hey All,

I am using Data Tables 1.9.4 and notice memory issue with my application while using events for multi row selection and polling for server data at specific intervals (using setInterval and fnDraw(false)). During every poll interval, when I highlight a row in the table, the memory usage goes up and never comes down until the page is reloaded. This is very high in IE8/9 and Firefox browsers.

Is there an issue with attaching events in the row selection function? Is there a better way to achieve that?

Here is the DataTables live link for the code...
http://live.datatables.net/ulemud/2/edit#javascript,html

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    You are adding an event handler on every draw. Do you really want to do that?

    You'd be much better using a single delegate event handler. `$('tbody').on('click', 'tr', function ()... )` for example.

    Allan
  • sdinesh21sdinesh21 Posts: 37Questions: 0Answers: 0
    Thanks a lot, Allan! I implemented your suggestion and noticed so far that the memory usage reduced significantly. I will test further and get back in case of further questions.
    I hope that the multi row selections with shift and ctrl key will be possible with future updates of TableTools...
  • sdinesh21sdinesh21 Posts: 37Questions: 0Answers: 0
    Hi Allan, The suggestion works perfect so far. I need to enhance this further... I am refreshing the table every 30 seconds and want to retain row selections (if any) after the refresh. What would be the best approach? Pls suggest.
    I have updated the DataTables live link here...
    http://live.datatables.net/ulemud/3/edit
This discussion has been closed.