How can I remove the dropdown blank below one column and not the others?

How can I remove the dropdown blank below one column and not the others?

VenoMVenoM Posts: 17Questions: 9Answers: 0

Greetings,

As the title states, I would like to remove one out of 6 drop-down form blanks below the columns.

Here is the screenshot of the table on my website: http://imgur.com/cyKdqoB

I would like to remove the form below the "Game Name" column.

This is the JavaScript i'm including for the blanks as well as some other elements in the table:

$(document).ready(function() {
    $('#example').DataTable( {
    "paging":   true,
    "ordering": false,
     "info":     true,
    "scrollY": "400px",
    "scrollCollapse": true,
  "  paging": true,
        initComplete: function () {
            this.api().columns().every( function () {
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.footer()).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>' )
                } );
            } );
        }
    } );
} );

And this is the URL of the page I'm using the table on: http://game-explorer.webege.com/table.html

Thank you in-advance. I don't know much JS so that is why I'm seeking help :) I hope someone can help.

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Any particular reason why you generate the select box with code? Why not put it directly in the html? Then you just need to attach your event handlers to the already existing select boxes

  • kthorngrenkthorngren Posts: 21,591Questions: 26Answers: 5,005

    The Javascript every() method has a parameter currentValue which appears, in this case, to be the column number. You want to skip column 0 so you can add this code:

    initComplete: function () {
      this.api().columns().every( function (currentValue) {
        if (currentValue !== 0) {    //add this line
    ..... your code .....
        }      //add this line
      } );
    }
    

    Kevin

This discussion has been closed.