Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda