Cannot add option "ordering":false before initComplete.

Cannot add option "ordering":false before initComplete.

Treq4950Treq4950 Posts: 5Questions: 2Answers: 0

I get a syntax error "Unexpected identifier" when attempting to add "ordering":false to remove ordering in my DataTable before the initComplete. I've tried going around by destroying the table and then reinitialising it, but for some reason the first column still has the arrows representing the ordering, even though it does not order. I'm very datatables so any help would be greatly appreciated! I've been stuck on this for hours

$(document).ready(function() {

    // Setup - add a text input to each footer cell
    $('#example thead th').each( function (i) {
        if(i!==6){
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="'+title+'" />' );
        }
    } );
    
    // DataTable
    var table = $('#example').DataTable({
        "ordering":false
        
        initComplete: function () {
            
            // Apply the search
            this.api().columns().every( function () {
                
                var that = this;
 
                $( 'input', this.header() ).on( 'keyup change clear', function () {
                    
                    if ( that.search() !== this.value ) {
                        that
                        
                            .search( this.value )
                            .draw();
                    }
                } );
            } );
        }
    });

} );

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406

    are you aware your code has a syntax error? Comma missing after "ordering": false

This discussion has been closed.