Sort Table By Column Removing Styling?

Sort Table By Column Removing Styling?

nikvenikve Posts: 19Questions: 2Answers: 0

http://celestialcaravan.com/List/

This is the site in question. When I add the default sorting, it removes all of the sorting, the styling, the search - everything - and becomes just black text in a column.

Where should I be putting it to prevent that? I want to sort by the ID column, #11.

<script>$(document).ready(function() {

    // Setup - add a text input to each footer cell
    $('#table_id tfoot th').each( function () {
        var title = $('#table_id thead th').eq( $(this).index() ).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );
 
 
    // DataTable
    var table = $('#table_id').DataTable(
{
        "bServerSide": true,
        "sAjaxSource": "***",
        "bProcessing": true,
    "iDisplayLength": 25,
    

});
 
    // Apply the search
    table.columns().every( function () {
        var that = this;
 
        $( 'input', this.footer() ).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
                                        
                                        
            }
        } );
                

    } );
} );

</script>

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    What code are you using to sort the table? Simply adding order: [[ 9, 'asc' ]] to your initialisation should work.

    Allan

  • nikvenikve Posts: 19Questions: 2Answers: 0
    edited August 2016

    Edit: I figured it out! Thanks for the help!

This discussion has been closed.