I am using a datatable in my application. When loading the page i need to display the number of rows of the table in a span. I am using table.data().count() to get the count of the rows. But its not giving correct value.
JSP:
<table id="example" class="" cellspacing="0" width="100%" style="padding: 10px">
<thead>
<tr>
<!-- <th>S No</th> -->
<th>Doc Id</th>
<th id="Position">Geo</th>
<th id="Position">Practice</th>
<th id="Position">Opportunity Id</th>
<th id="Position">Reference Id</th>
<th id="Position">Status</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Jquery:
var table = $('#example').DataTable();
$(document).ready(function() {
var rowCount = table.data().count();
alert(rowCount);
});