Sorting enabled when it should not
Sorting enabled when it should not
mathie
Posts: 36Questions: 0Answers: 0
Summary: The table is automatically sorted when it should display in original order. The test is a simple table with only one column (name).
Version: 1.5.4d
Header: Name
Data: row1=Betty, row2=Albert, row3=Alfred
Options: {"bSortable":false}
[code]
Name
BettyAlbertAlfred
$(document).ready(function() { $("#myTable").dataTable({
"bJQueryUI":true,"bAutoWidth":false,"bStateSave":false,
"bPaginate":false,"bFilter":false,"aoColumns":[{"bSortable":false}]}
);});
[/code]
The table is displayed with Betty at the bottom.
Thanks,
Son
Version: 1.5.4d
Header: Name
Data: row1=Betty, row2=Albert, row3=Alfred
Options: {"bSortable":false}
[code]
Name
BettyAlbertAlfred
$(document).ready(function() { $("#myTable").dataTable({
"bJQueryUI":true,"bAutoWidth":false,"bStateSave":false,
"bPaginate":false,"bFilter":false,"aoColumns":[{"bSortable":false}]}
);});
[/code]
The table is displayed with Betty at the bottom.
Thanks,
Son
This discussion has been closed.
Replies
I don't believe that this is actually a bug in DataTables - but rather more of a grey area :-). You haven't disabled sorting (bSort), and as such DataTables will attempt to sort on the first column by default. If you had more that one column, and you wanted others to be sortable, you would use aaSorting: [[1, 'asc']] (for example) to make the sorting occur on the second column by default.
One could say that this is wrong and DataTables shouldn't attempt to sort the first column if it is initially non-sortable. However, I wanted to leave it flexible such that you have the sorting occur initially, and then not in future (a bit of a back-handed trick really, but it could be useful :-) ).
So in the case of your one column table above, I'd suggest bSort:false. In a multiple column table, aaSorting with your required default.
Regards,
Allan
Or a check could be made to see if any column is sortable, if not, turn off sorting. Right now I'm doing this logic in my generic PHP class that generates the HTML/JS code.
Son
I think that the argument of not having sorting enabled on any column, but still doing an initial sort (perhaps the original table data is unsorted, and you want to have it sorted, but not allow the user to define the sorting for whatever reason...) is equally part of the 'grey' area of this particular subject in DataTables. As this could actually be useful, and increases the flexibility of DataTables, I will be leaving sorting turned on, even if all columns are marked as unsortable for the moment.
Having said that, yes I agree that the documentation could do with a bit of clarification on this topic and I'll look at this shortly.
Regards,
Allan
Thanks,
Son
Yes they probably should! I'll have a look at this and get back to you on a fix.
Regards,
Allan
No, that's not the case. You can disable the auto sort that DataTables performs on initialisation by setting the aaSorting parameter to being an empty array, eg:
[code]
$(document).ready( function() {
$('#example').dataTable( {
"aaSorting": []
} );
} );
[/code]
Regards,
Allan
Any update on "bSort:false" and no jQueryUI theme on headers?
Thanks
Son
Not yet I'm afraid - all the time I've had for DataTables this week has been support stuff rather than development really :-(. I'll try to look at it soon though. It's no. 1 on my do to list.
Regards,
Allan
Quick update on this - the issue is now addressed by v1.5.5. This should work nicely for you now :-)
Regards,
Allan