Yaco Zaragoza
Yaco Zaragoza

Reputation: 437

Sorting DataTable

I am trying to sort my bootstrap-datatable using the HTML5 attribut data-order but it does not seem to be working.. I want the biggest Work Order Number to show 1st

Can anyone help me out and let me know what I am doing wrong?

This is what my code looks like

<table class="table table-striped table-bordered bootstrap-datatable datatable responsive" data-order="WO">
<thead>
    <tr>
        <th>WO</th>
        <th>Client Name</th>                
    </tr>
</thead>
<tbody>
    <tr>
        <td>1</td>
        <td>ABC</td> 
    </tr>

    <tr>
        <td>2</td>
        <td>DEF</td> 
    </tr>
    <tr>
        <td>3</td>
        <td>GHI</td> 
    </tr>  
</tbody>                        

This is what I have in my JavaScript

$('.datatable').dataTable({
    "order": [0, "desc"],       
    "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span12'i><'span12 center'p>>",
    "sPaginationType": "bootstrap",
    "oLanguage": {
        "sLengthMenu": "_MENU_ records per page"
    }
} );    

Upvotes: 0

Views: 217

Answers (2)

Abdelrahman M. Allam
Abdelrahman M. Allam

Reputation: 922

Change "order": [0, "desc"] to "order": [[0, "desc"]]

Upvotes: 0

bpeterson76
bpeterson76

Reputation: 12870

You're using the 1.10 API method with an older version it appears. Here's a conversion document to show you the old vs. new terminology. You mention HTML5 sort method, but I don't think you're trying that at all....this is a simple column sorting example.

For what you're doing, it appears you want aaSorting

Here is the old API reference to give you an example.

Upvotes: 1

Related Questions