Pagination not working on asp classic implementation

Pagination not working on asp classic implementation

lzamoraglzamorag Posts: 1Questions: 1Answers: 0
edited June 2019 in Free community support

Hi, datatables is an amazing plugin, I would like to contribute some way after I finish the project I'm working with,
I'm using datatables in a project developed with classic asp, but when the server-side mode is on the pagination doesn't work. Here is the code I'm using:

****JAVASCRIPT****

<script>
        var $j = jQuery.noConflict();
        $j(document).ready( function () {
            $j('#tablaPersonalActividades').DataTable( {
                "processing": true,
                "serverSide": true,
                ajax: {
                    url: 'csbListaActividadPersonaBackend.asp',
                    dataSrc: 'data',  
                    dataType: 'json',
                    type: 'POST',
                    dataFilter:function(data){
                        console.log(data);
                        return data;
                    }
                },
                "columns": [
                    { "data": "IdPersonal" },
                    { "data": "NombreS" },
                    { "data": "ApellidoPaterno" },
                    { "data": "ApellidoMaterno" },
                    { "data": "descActividad" },
                    { "data": "peso" },
                    { "data": "meta" }
                ]
                ,
                "language": {
                    "lengthMenu": "Mostrando _MENU_ registros por p&aacute;gina",
                    "zeroRecords": "No se han encontrado registros",
                    "info": "Mostrando p&aacute;gina _PAGE_ de _PAGES_",
                    "infoEmpty": "Informaci&oacute;n no disponible",
                    "infoFiltered": "(filtered from _MAX_ total records)",
                    "search": "Buscar:",
                    "paginate": {
                        "first":      "Primero",
                        "last":       "&Uacute;ltimo",
                        "next":       "Siguiente",
                        "previous":   "Anterior"
                    }
                }
            } );
        });
        
    </script>

****HTML****

                 <table id="tablaPersonalActividades" class="display">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Nombre</th>
                                <th>Appelido Materno</th>
                                <th>Apellido Paterno</th>
                                <th>Actividad</th>
                                <th>Peso</th>
                                <th>Meta</th>
                            </tr>
                        </thead>    
                    </table>

****ASP****

        set JSON = New JSONobject

        draw = CInt(Request("draw"))
        recordsTotal = Request("recordsTotal")
        recordsFiltered = Request("recordsFiltered")

        sqlActividades = "SELECT IdPersonal,NombreS, ApellidoPaterno,ApellidoMaterno, descActividad,peso,meta " 
        
        strCond = "FROM Personal JOIN csbObjetivoPersonal " 
        strCond = strCond & "ON (Personal.IdPersonal = csbObjetivoPersonal.personalId) " 
        strCond = strCond & "WHERE csbObjetivoPersonal.estatus = 1 "

        
        set rsActividadPersonal = getrs(conn,sqlActividades & strCond)

        sqlTotalActividades= "SELECT COUNT(*) AS totalActividades "

        registros = getBDnum("totalActividades",sqlTotalActividades & strCond)

        JSON.defaultPropertyName = "data"
        
        JSON.draw = draw
        
        JSON.recordsTotal = registros

        JSON.recordsTotal = registros

        JSON.LoadRecordset rsActividadPersonal

        Response.CharSet = "utf-8"
        Response.ContentType = "application/json"
        
        Response.Write JSON.Write()     

I have spent sometime already trying to find out where is the fail with no look.

Thank you very much in advance.

Regards

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    You don't appear to be handling any of the paging properties that DataTables sends with a server-side processing request - e.g. 'length' and 'start'.

    Do you actually need server-side processing? Do you have tens of thousands or more records?

    Allan

This discussion has been closed.