Problem sorting Datatables in serverSide mode

Problem sorting Datatables in serverSide mode

rogerio.2progerio.2p Posts: 1Questions: 0Answers: 0

Good morning people.
Sorry for using Google Translate.
I'm doing an implementation of DataTables in Serverside mode. Some columns are not being sorted correctly. In this case, only the city and state are working. The search is the same for all fields. I could not find why it did not work.
Any help will be welcome.
Here is the code I've implemented so far.

Thank you

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <table id="employee-grid"  cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                            <thead>
                                <tr>
                                    <th class="alinhar_tabelas">Nome do gerente</th>
                                    <th class="alinhar_tabelas">Nome do representante</th>
                                    <th class="alinhar_tabelas">Data do cadastro</th>
                                    <th class="alinhar_tabelas">Nome da empresa</th>
                                    <th class="alinhar_tabelas">Nome do usuário</th>
                                    <th class="alinhar_tabelas">Categoria</th>
                                    <th class="alinhar_tabelas">Cidade</th>
                                    <th class="alinhar_tabelas">Estado</th>
                                    <th class="alinhar_tabelas">Plano</th>
                                    <th class="alinhar_tabelas">Valor do plano</th>
                                    <th class="alinhar_tabelas">Forma de pagamento</th>
                                    <th class="alinhar_tabelas">Status
                                    <th class="alinhar_tabelas">Ação</th>
                                    <th class="alinhar_tabelas">Ação</th>
                                    <th class="alinhar_tabelas">Ação</th>                           
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>



    $(document).ready(function() {
        var dataTable = $('#employee-grid').DataTable( {
            responsive: false,
            "order": [[ 2, "desc" ]],
            "aoColumns": [
                null,
                null,
                { "sType": "date-uk" },                 
                null,
                null,
                null,   
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,                   
                null
            ],              
            //"scrollY": 400,
            "scrollX": true,
            "iDisplayLength": 6, //100
            "processing": true,
            "serverSide": true,
            "ajax":{
                url :"../php/datatables/cadastro_geral.php", // json datasource
                type: "post",  // method  , by default get
                error: function(){  // error handling
                    $(".employee-grid-error").html("");
                    $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">Nenhum resultado encontrado</th></tr></tbody>');
                    $("#employee-grid_processing").css("display","none");
                }
            }
        } );
    } );

    jQuery.extend( jQuery.fn.dataTableExt.oSort, {
        "date-uk-pre": function ( a ) {
            var ukDatea = a.split('/');
            return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
        },

        "date-uk-asc": function ( a, b ) {
            return ((a < b) ? -1 : ((a > b) ? 1 : 0));
        },

        "date-uk-desc": function ( a, b ) {
            return ((a < b) ? 1 : ((a > b) ? -1 : 0));
        }
    } );

cadastro_geral.php

This discussion has been closed.