Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82506

Count number of rows before and after reload

$
0
0

I have set an interval to reload the DataTable every XY seconds, what I want to do is count the number of rows before the reload, and after, in case the number of rows are higher after the refresh I want to display an alert that a new reservation was made.

This is the code:

setInterval( function () {


                                var  rows = table.rows().count();
                                table.ajax.reload();
                                var  rows2 = table.rows().count();

                                if(rows2>rows) {
                                    alert('New reservation');
                                }
                            }, 3000 );

The output of rows and rows2 are the same, which are the number of rows AFTER the reload.
I looked at this post: https://datatables.net/forums/discussion/12613/fnreloadajax-count-rows-before-after
but couldnt get it to work, newLength = table.fnGetData().length; outputs nothing


Viewing all articles
Browse latest Browse all 82506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>