The best approach is to get the counts first and then try to get specific column;
var table = $('#example').DataTable();
var data = table
.rows()
.data();
alert( 'The table has '+data.length+' records' );
The DataTables columns() and column() (also optionally cells() and cell()) methods provide the ability to select columns from the table. Which columns are selected and how the selector actually operates is controlled by this column-selector data type.
var table = $('#example').DataTable( {
columns: [
{ name: 'first-name' },
{ name: 'last-name' },
{ name: 'position' },
{ name: 'location' },
{ name: 'salary' }
]
} );
// Get salary column data
table.column( 'salary:name' ).data();
Reference
https://datatables.net/reference/type/column-selector
https://stackoverflow.com/questions/32598279/how-to-get-name-of-datatable-column
https://datatables.net/reference/api/columns().every()
https://datatables.net/reference/api/rows().data()

Add to favorites