datatable sorting issue

datatable sorting issue

pinasispinasis Posts: 3Questions: 0Answers: 0
edited January 2014 in Bug reports
Hello,
I want my datatable to sort through id from the 0th column. but when i set the code to "aaSorting": [[ 0, 'asc' ]]. Sorting goes out of order. I am using a counter to just count the records and the result is shown like this
1
11
12
29
30
4
5
6
and so on. Can you please help me out here.
my function looks like this.

$(document).ready(function(){
$('#datatables_paid').dataTable({
"sPaginationType":"full_numbers",
"aaSorting":[[0, "asc"]],
"sType": "num-html",
"bJQueryUI":true
});
})


Thanks.

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Sounds very much like you have non-numeric data in the column. Can you link to a test case showing the problem so I can say what is actually going wrong please.

    Also, sType is a property of aoColumns or aoColumnDefs . See the examples in the documentation.

    Allan
  • pinasispinasis Posts: 3Questions: 0Answers: 0
    Hello Alan,
    Thank you for your response.
    Do you want a screenshot of the page that I am working on?. If so how can i attach the document in this page. and sorry about the stype. I was just experimenting and forgot to remove it from the js.

    1st column
    <% if @var.count > 0 %>
    <% cnt = 0 %>
    <% @var.each do |c| %>
    <% cnt = cnt+1 %>

    <%= cnt %>
    this is the 1st column or 0th index. I am writing the code in ruby on rails.
    Problem is as soon as I remove the js for datatable the data pretty much shows in ascending order. But the moment I put datatable js the sorting goes wayward. I don't understand the problem.
  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    >

    That's the problem.

    Can you try DataTables 1.10-dev perhaps? http://datatables.net/download/ (the 'nightly'). It has HTML number type detection and sorting built-in.

    Allan
  • pinasispinasis Posts: 3Questions: 0Answers: 0
    Yes, Thanks a lot. Indeed, tag was the problem I think html combined with number type was the problem.
    I had to pass the id from the database using display none and arrange it in a descending way as an alternate solution.
    But this is much better
    Thanks again for the solution. :)
This discussion has been closed.