Table incorrectly sorts on 1st column
Table incorrectly sorts on 1st column
Lone Shepherd
Posts: 11Questions: 0Answers: 0
I have a table which is initialized with aoColumns and bSortable set to false for the first four rows, however the table always shows up with the first column td having the sorting_1 class applied.
I assume this is some sort of default? I'd prefer when the table is initialized for no sorting or sorting styles to be applied.
I assume this is some sort of default? I'd prefer when the table is initialized for no sorting or sorting styles to be applied.
This discussion has been closed.
Replies
For first column to initialized for no sorting you can put
[code]
"aoColumns": [
{ "bSortable": false }, //First Column
..... //Set for rest of the columns
],
//Set other properties
[/code]
More help on http://www.datatables.net/usage/columns
Hence, the problem -- it doesn't seem to be working.
oTable = $('#logTable').dataTable({
'bAutoWidth': false,
'bFilter': false,
'bInfo': false,
'bJQueryUI': true,
'bPaginate': false,
'sDom': 't',
'oLanguage': { 'sEmptyTable': 'Empty table text.' },
'aoColumns': [
{'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
{'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
{'bSortable': false },
{'bSortable': false, 'sWidth': '7em' },
{'sWidth': '4.5em' },
{'sWidth': '4.5em' },
{'sWidth': '4.5em' },
{'sWidth': '4.5em' },
{'sWidth': '5em'}
]
});
[/code]
That's the code to initialize my table. When I view the table, it appears to be sorted by the first column -- the background colors are different, and each td element in the first column has the sorting_1 class applied.
You miss closing quote after myclass on line 10. Change to
[code]
{'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
[/code]
I tried with this and working for me.
I do not get any syntax errors with my actual table; it works fine, other than being sorted by default on column 1.
[code]
DataTables example
@import "demo_page.css";
@import "demo_table.css";
$(document).ready(function() {
oTable = $('#example').dataTable({
'bAutoWidth': false,
'bFilter': false,
'bInfo': false,
'bJQueryUI': true,
'bPaginate': false,
'sDom': 't',
'oLanguage': { 'sEmptyTable': 'Empty table text.' },
'aoColumns': [
{'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
{'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
{'bSortable': false },
{'bSortable': false, 'sWidth': '7em' },
{'sWidth': '4.5em' }
]
});
} );
Rendering engine
Browser
Platform(s)
Engine version
CSS grade
Trident
Internet
Explorer 4.0
Win 95+
4
X
........
Rendering engine
Browser
Platform(s)
Engine version
CSS grade
[/code]
Regards,
Allan