I have trouble to get count datatables, i need to chect that table is emtpy or not, this my code :
var table = $("#tbl_tmppo");
var target = table.attr('data-table');
var oTable = table.on( 'processing.dt', function ( e, settings, processing ) {
if (processing) {
$(this).find('tbody').addClass('load1 csspinner');
} else{
$(this).find('tbody').removeClass('load1 csspinner');
};
} ).DataTable({
"bServerSide": true,
"ajax": host+'datatable/'+target,
"columnDefs": [{
"targets": [ -1 ],
"className": "dt-body-left",
}]
});
i'm kinda stuck in here, i wanna check if i dont have data on Otable, i need do something, if not i need to something else. Anyone can help me??
Update : I was using like oTable.Data().length, but it always show 0 length to me even i have 2 record on that table. if i use oTable.Data().count() is show error not undifined.
CLOSED. Tq for kcp code
oTable.on('draw', function () {
/* Now you can count rows */
var count = table.data().count()-1;
});
so i can get count my data. Tq kcp!!! U're awsome!!