0

I'm using jQuery DataTables to build a grid, with AJAX loaded data and pagination.

I built a form to create a new record, save it on the database and reload the grid. I would like to selected the last inserted record.

The problem is: the grid only shows 10 records. How would be the logic to calculate in what page the last row will appear to navigate to it?

fonini
  • 3,243
  • 5
  • 30
  • 53
  • This question is a little short on information. Can you share what you have tried, and what problems you have run into? – Jay Blanchard May 15 '15 at 18:21
  • possible duplicate of [MySQL get row position in ORDER BY](http://stackoverflow.com/questions/3614666/mysql-get-row-position-in-order-by) – cmorrissey May 15 '15 at 18:48

1 Answers1

0

After your record is added you can refresh the table details like bellow

var oTable = jQuery('#infotable').dataTable({
//your code
 });

now after new record added success after ajax just call fnDraw. it will load your newly added record

jQuery.ajax({
                type: 'POST',
                url: 'your url',
                data: yourdata,
                success: function(data){
                    oTable.fnDraw();
                }
            });
Vishal Wadhawan
  • 1,085
  • 1
  • 9
  • 11