My filter by column doesn't work

My filter by column doesn't work

xiulxiul Posts: 7Questions: 3Answers: 0
edited December 2018 in Free community support

I really appreciate if anyone could help me with my datatable because it is not working and I don't know why, Post my code below.

                detalle = $("#detalle-table").DataTable({
                    "ajax": {
                        url: "ajax/cargar_reportedetalle",
                        type: "POST",
                        data: {
                            idsocio: idsocio,
                            idusuario: idusuario
                        },
                        dataSrc: "",
                        complete: function(data){
                            if(Object.keys(data.responseJSON).length == 3){
                                var mensaje = data.responseJSON.mensaje;
                                if(mensaje != null){
                                    alert(mensaje);
                                }
                            }
                        }
                    },
                    columns: [
                        { data: "contador" },
                        { data: "idtipounidad" },
                        { data: "idunidad" },
                        { data: "idcarroceria" },
                        { data: "noeconomico" },
                        { data: "marca" },
                        { data: "modelo" },
                        { data: "placas" },
                        { data: "tipounidad" },
                        { data: "socio" },
                        { data: "km" },
                        { data: "estatus" },
                        { data: "serie"}
                    ],
                    columnDefs: [
                        { className: "cssbold text-center", targets: [0] },
                        { className: "text-center", targets: "_all" },
                        { "targets": [ 1 ], "visible": false },
                        { "targets": [ 2 ], "visible": false },
                        { "targets": [ 3 ], "visible": false }
                    ],

                    initComplete: function () {
                        var r = $('#detalle-table tfoot tr');
                        r.find('th').each(function(){
                            $(this).css('padding', 8);
                        });
                        $('#detalle-table thead').append(r);
                        detalle.columns().every( function () {
                            var that = this;

                            $( 'input', this.footer() ).on( 'keyup change', function () {
                                if ( that.search() !== this.value ) {
                                    that
                                    .search( this.value )
                                    .draw();
                                }
                            } );
                        } );
                    },
                    autoWidth: false,
                    searching: false,
                    info: false,
                    pageLength: 10,
                    pagingType: "full_numbers",
                    fixedHeader: {
                        header: true,
                        footer: true
                    }
                });
            });

            var contador = 0;
            $('#detalle-table tfoot th').each( function () {
                var title = $(this).text();
                if(contador > 0){
                    $(this).html('<input type="text" id="filtro' + contador + '" class="form-control form-control-sm"' 
                        + 'style="width: 100%;" placeholder="Buscar ' + title + '" />');
                }
                contador++;
            } );

Answers

This discussion has been closed.