0

Tengo este dilema con Datatable. Cargo los datos en el datatable e inicializo perfectamente con este codigo:

$(document).ready(function () {

        $('.table').DataTable({
            sScrollX: false,
            dom: 'Bfrtip',
            //Elijo que tamanio tendran las columnas
            aoColumnDefs: [
                { sWidth: "5%", "aTargets": [0] },
                { sWidth: "10%", "aTargets": [1] },
                { sWidth: "65%", "aTargets": [2] },
                { sWidth: "10%", "aTargets": [3] },
                { sWidth: "5%", "aTargets": [4] },
                { sWidth: "5%", "aTargets": [5] }
            ], columnDefs: [
                { responsivePriority: 5, targets: -1 },
                { responsivePriority: 4, targets: 3 },
                { responsivePriority: 3, targets: 2 },
                { responsivePriority: 2, targets: 1 },
                { responsivePriority: 1, targets: 0 }

            ],
            pageLength: 10,
            lengthChange: true,
            paging: true,
            responsive: false,

            language: {
                "lengthMenu": "Mostrando _MENU_ Datos por página.",
                "zeroRecords": "No hay existen registros para los filtros seleccionados.",
                "info": "Página _PAGE_ de _PAGES_",
                "infoEmpty": "No hay datos registrados",
                "infoFiltered": "(Filtrado de _MAX_ datos totales.)",
                "paginate": {
                    "first": "Primera",
                    "last": "Ultima",
                    "previous": "<",
                    "next": ">"
                },

            }

        });
        $("#gridTable_filter input").attr("id", "inputFiltro");
        $('#gridTable_filter').css("display", "none");
        $('.dataTables_info').css("margin-left", "2%");
    });

Pero oculto el textbox de Busqueda y el de Pagination al inicializarla Algo que se puede ver al final.

  $("#gridTable_filter input").attr("id", "inputFiltro");
        $('#gridTable_filter').css("display", "none");
        $('.dataTables_info').css("margin-left", "2%");

Pero cuando hago un search y traigo datos actualizados por medio de Ajax, No puedo ocultar y aparecen nuevamente.

  // Do a New Search
    function DoSearch() {
        var _Name = $('#txtName_Filter').val();
        var _TypeCfe = $('#txtTypeCfe_Filter').val();
        var _Active = null;




        if (_Name == "") { _Name = null; }
        if (_TypeCfe == 0) { _TypeCfe = null; }
        if ($("#chkActive_Filter").is(":checked")) { _Active = true; }


        var _data = {
            Name: _Name,
            CfeType: _TypeCfe,
            Active: _Active
        };
        $.ajax(
        {
            url: '@Url.Action("RefreshDocumentModelsList", "SystemSettings")'
            , type: "GET"
            , data: _data
            , contentType: 'application/json'
        })
        .done(function (result) {
            $("#divList").html(result);
            // #region DataTable

            $('.table').DataTable({
            });

            // #endregion
        })
        .fail(function (e) {
            swal({
                title: 'Error',
                text: e.Message,
                type: 'warning'
            });
        });
        $("#gridTable_filter input").attr("id", "inputFiltro");
        $('#gridTable_filter').css("display", "none");
        $('.dataTables_info').css("margin-left", "2%");
    }

Ejemplo Como esta antes y despues

1 respuesta 1

2

Podría añadir este parámetro searching: false para des habilitar la búsqueda y paging: false para la páginación, al objeto de configuración de DataTable.

Para versiones mayores a 1.10

$('table').dataTable({searching: false, paging: false});

Para versiones menores a 1.10

$('table').dataTable({bFilter: false, bInfo: false});
1
  • Gracias, es una buena solucion, sabes yo los oculto, porque a veces agrego un input personalizado donde uso el Searching ese. el 12 feb. 2018 a las 16:02

Tu Respuesta

Al pulsar en “Publica tu respuesta”, muestras tu consentimiento a nuestros términos de servicio, política de privacidad y política de cookies

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.