How to get total rows

How to get total rows

vuceticavucetica Posts: 15Questions: 0Answers: 0
edited August 2009 in General
When I return data from the server, I put total nunber of rows in iTotalRecords property. Is there any function to get this value on the clients side? Something like oTable.fnGetTotalRows... Thanks!

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi vucetica,

    There sure is! This kind of information is stored in the DataTables settings object for each individual table. You can get this object for your table by using the fnSettings() function and there is a function to get the property you specifically want: fnRecordsTotal(). I.e.:

    [code]
    var oSettings = oTable.fnSettings();
    var iTotalRecords = oSettings.fnRecordsTotal();
    [/code]

    Other functions of interest:
    fnRecordsDisplay() - records in the 'display' (i.e. after filtering)
    fnDisplayEnd() - End point of the current 'page'
    _iDisplayStart - Start point of the current 'page'
    _iDisplayLength - Length of records for the current 'page'.

    Hope this helps.

    Regards,
    Allan
  • neburtonneburton Posts: 63Questions: 6Answers: 0
    I'm trying to use these settings with an ajaxsource, but the result is 0. I'd like to take the value and show it elsewhere on my page after the table has loaded. Any suggestion?
  • gishnetworkgishnetwork Posts: 7Questions: 0Answers: 0
    neburton, try putting your call inside fnInitComplete so it runs after table is fully initialzed - that is what I had to do.
This discussion has been closed.