datatable sorting issue
datatable sorting issue
pinasis
Posts: 3Questions: 0Answers: 0
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.
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.
This discussion has been closed.
Replies
Also, sType is a property of aoColumns or aoColumnDefs . See the examples in the documentation.
Allan
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.
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
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. :)