how to get max value

how to get max value

irvansychrldiirvansychrldi Posts: 5Questions: 2Answers: 0
edited July 2020 in Free community support

Link to test case:
Debugger code (debug.datatables.net):
$("#NilaiAkhir").DataTable({
processing: true,
serverSide: true,
scrollCollapse: true,
responsive: true,
scrollY : true,
scrollX : true,
ajax:'{!! route('admin.topsis.hasil_akhir')!!}',
order:[0,'desc'],
columns:[
{data:'id', name: 'id'},
{data:'nama', name: 'nama'},
{data:'r_makan',name:'r_makan'},
{data:'r_infeksi',name:'r_infeksi'},
{data:'r_sanitasi',name:'r_sanitasi'},
{data:'r_asuh',name:'r_asuh'},
{data:'r_pangan',name:'r_pangan'},
{data:'r_miskin',name:'r_miskin'},
{data:'r_pendidikan', name:'r_pendidikan'},
],
"drawCallback": function () {
this.api().rows().every( function ( ) {
var data = this.data();
var values = data.slice(1).map(Number);
console.log( data[0] + ': ' + Math.max( ...values ) );
} );
}
});
Error messages shown: TypeError: data.slice is not a function
Description of problem:
My Datatable

1 Nagrog 0.314 0.314 0.311 0.366 0.524 0.601 0.468
2 Babakan 0.419 0.524 0.518 0.244 0.314 0.481 0.468
3 Dampit 0.419 0.419 0.518 0.366 0.314 0.481 0.374

I want to get the maximum value from the table, and my expectations are like this :

1 Nagrog 0.601
2 Babakan 0.524
3 Dampit 0.518

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    My example in this thread should, it's showing how to get the highest value for each column,

    Colin

This discussion has been closed.