Sorting with checkbox as the first column

Sorting with checkbox as the first column

novPatnovPat Posts: 4Questions: 0Answers: 0
edited October 2012 in General
I have a fair simple datatable with id in the first column, checkbox at the second column.
The first column invisible and the second column (the checkbox disappear), so the first load the sorting arrow is disappear with this setting


$('#example').dataTable({
"bRetrieve": true,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] },
{ "bVisible": false, "aTargets": [0] },
{ "bSortable": false, "sSortDataType": "dom-checkbox" , "aTargets": [1] }
]
});


My checkbox in the html is simply like that




However, after the sorting.
The sorting arrow for the check box column appears again.

Replies

  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    By default the sorting applied to the table is `[[0, 'asc']]` - i.e. the first column ascending, but it sounds like you want the second column to be sorted on initially, so you could add:

    [code]
    aaSorting: [[ 1, 'asc' ]]
    [/code]

    to your DataTables initialisation and that should do it.

    Allan
  • novPatnovPat Posts: 4Questions: 0Answers: 0
    Not working, actually, i found the problem is not related to checkbox.
    Any column i added the bSortable:false looks good at the beginning. The sorting triangle is not there
    Then after a click.They resume to normal. The sorting triangle is still there.
  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    I think I'd need a link to a demo page showing the issue to be able to offer much help then I'm afraid. I need a way to reproduce the problem to be able to diagnose and resolve it.

    Allan
  • novPatnovPat Posts: 4Questions: 0Answers: 0
    okay, i solved by updated to the latest version of datatable.
This discussion has been closed.