Count number or rows
Count number or rows
silens
Posts: 101Questions: 40Answers: 0
Buenas, me gustaría poder contar el registro total de una tabla. Saber si es posible acceder al valor de datatable "info" con el contador total.
He probado esto y otros códigos pero siempre da 0. Creo que se ejecuta antes que la tabla. como puedo acceder al numero total de registros.
var oTable = $('#tblVentas').DataTable();
var info = oTable.page.info();
var count = info.recordsTotal;
alert(count);
Count siempre es 0
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The above code should work. However if you are not showing all your code and performing an ajax request within your Datatables init code then yes you are correct that
oTable
doesn't exist whenvar info = oTable.page.info();
executes. In this case you would put that code inside theinitComplete
option.Kevin