Retrieve table info

Retrieve table info

nvillescasnvillescas Posts: 3Questions: 0Answers: 0
edited November 2011 in General
I'm trying to display the table information (i.e. "Showing 1-10 of 20") in an external div. I know you can customize the placement of "i" inside the sDom property, but that's not meeting my needs. Instead I have a div that resides in a completely different area of the web page that I'd like to show the table information and update whenever the table redraws.

For example:

[code]oTable = $('#datatable').dataTable(
{
'fnDrawCallback' : function()
{
$('.table_info').html(fnGetTableInfo);
}
});[/code]

In the above example, whenever the table gets redrawn, the ".table_info" div will update with the new table info (i.e. "Showing 1 - 10 of 20").

I can't find any type of function that will easily do this. Any help is greatly appreciated. Thanks!

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    http://datatables.net/ref#fnInfoCallback is the callback you want for this :-). One of the parameters is the rendered string, which you can just dump into your external DIV using standard DOM or jQuery methods.

    Allan
  • nvillescasnvillescas Posts: 3Questions: 0Answers: 0
    Ah that's perfect. I looked at that function before but never fully understood the sPre argument. Thanks for all you hard work on such an amazing plugin!

    For those interested, here's the solution:

    [code]oTable = $('#datatable').dataTable(
    {
    'fnInfoCallback' : function(oSettings, iStart, iEnd, iMax, iTotal, sPre)
    {
    $('.table_info').html(sPre);
    }
    });[/code]
  • nvillescasnvillescas Posts: 3Questions: 0Answers: 0
    Also note, you still need to have "i" listed somewhere in the sDom property. Without it, the fnInfoCallback doesn't get triggered.
This discussion has been closed.