Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
Server side scripting issue

I have written the server-side scripting to show a large amount of data and it's working fine, but I want to show the sum in the footer of the points column. The code is written in a laravel blade file.

The footer calls back function, not working it is showing me an error ie an undefined length object, please let me know where I am making the mistake.

<table class="table table-bordered yajra-datatable" width="100%" style="color:#8D1B6B;margin-top:20px;">
    <thead>
        <tr>
            <td><b>Sr No</b></td>
            <td><b>Date</b></td>
            <td><b>Activity Name</b></td>
            <td><b>Activity Marks</b></td>
            <td><b>My Rewards</b></td>
        </tr>
    </thead>
<tbody>

</tbody>
<tfoot>

</tfoot>
</table>

The script written for the above code is

<script>
        $(document).ready(function(){
            var table = $('.yajra-datatable').DataTable({
                processing: true,
                serverSide: true,
                ajax: "{{ route('abc') }}",
                columns: [
                    {data: 'DT_RowIndex', name: 'DT_RowIndex'},
                    {data: 'activityDate', name: 'activityDate'},
                    {data: 'activity', name: 'activity'},
                    {data: 'point', name: 'point'},
                    {
                        data: 'action',
                        name: 'action',
                        orderable: true,
                        searchable: true
                    },
                ],
                "footerCallback": function (row, data, start, end, display) {
                    var api = this.api(), data;
                    // Remove the formatting to get integer data for summation
                    var intVal = function ( i ) {
                        return typeof i === 'string' ? i.replace(/[\$,]/g, '')*1 : typeof i === 'number' ? i : 0;
                    };
                    // Total over all pages
                    data = api.column( 3 ).data();

                    total = data.length ? data.reduce( function (a, b) {
                        return intVal(a) + intVal(b);
                    }) : 0;

                    // Total over this page
                    data = api.column( 3, { page: 'current'} ).data(); pageTotal = data.length ? data.reduce( function (a, b) { return intVal(a) + intVal(b); } ) : 0;

                    // Update footer
                    $( api.column( 3 ).footer() ).html( '$'+pageTotal +' ( $'+ total +' total)' );
                }
            });

           
        });
    </script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda