who create a searching columns rows before hide first column

who create a searching columns rows before hide first column

jjcfidalgo@gmail.comjjcfidalgo@gmail.com Posts: 11Questions: 8Answers: 0
edited January 2022 in General

I need hide and sorting the first column.
In columns 2,3,4 a need put a dropdownlist to shearch
Who do that
I try this but don't works

  var table = $('#grid').DataTable({
        //orderCellsTop: true,
       // responsive: true,
        fixedHeader: true,
        "scrollX": true,
        "order": [[0, "desc"]],

 // Hidden part
"columnDefs": [
    { "visible": false, "targets": 0 }
],
  
        initComplete: function() {
            this.api()
              .columns([1,2,3])
              .every( function () {
                var column = this;
                var select = $('<select class="custom-select custom-select-sm form-control form-control-sm"><option value=""></option></select>')
                  .appendTo( $("thead tr:eq(1) td").eq(column.index()).empty() )
                  .on( 'change', function () {
                    var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val());
                    column
                        .search( val ? '^' + val + '$' : '', true, false ).draw();
                  });
    
                  column
                    .data()
                    .unique()
                   /// .sort()
                    .each( function ( d, j ) {
                      select.append( '<option value="' + d + '">' + d + '</option>' );
                  });
            });
          
        },
      
    });

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

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.