does exists any way to order row selected with checkboxes made with Select extension?

does exists any way to order row selected with checkboxes made with Select extension?

rivaldidrivaldid Posts: 55Questions: 6Answers: 2
edited February 2016 in Free community support

this is the scenario: I got the table, I choose the rows and I need to have my rows all at the beginning of the table, I wish do this with the ordering native of DataTable.

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    You should just be able to use the order api. It will order based upon the content of a cell.

    https://datatables.net/reference/option/order

  • rivaldidrivaldid Posts: 55Questions: 6Answers: 2

    It's not working because I guess the checking action is an ::after

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    Okay, I understand. Sorting is based upon memory and not upon the DOM. So, a check action really needs to update your .data() so the value gets pushed back into memory.

    When a checkbox is part of the underlying record, I perform a database update and reload the row so it's in memory, that's what I was thinking in my response.

    But, when a checkbox is a select option only, I disabled the sort. I think I need to go back and modify that. Currently in my code, a search/filter will also lose the selected rows. And if doing a serverside, the selected rows are really lost (because that select exists no where when the ajax is returned). I can solve the natively loaded table by pushing the selected option back into the dom easy enough, but not sure about the serverside select.

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    Have you looked at the select() plugin / extension? That might be of interest to you.

  • rivaldidrivaldid Posts: 55Questions: 6Answers: 2

    I have tried the live dom sorting and exists a checkboxes one, but it's not working. Don't know why, it looks like it don't find the modified dom with ::after

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    This recent commit made it possible. It will be included in the next release of the Select extension (in the next few days).

    Allan

  • rivaldidrivaldid Posts: 55Questions: 6Answers: 2

    Still not working, the table don't got sorted clicking the column header upon the checkboxes column.

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    You have real checkboxes, or checkboxes provided by Select? Please link to a page showing the issue (per the forum rules).

    If you have real checkboxes you'd need to use live DOM sorting as @glenderson suggested. If it isn't working, we can't help without a test case.

    Allan

  • rivaldidrivaldid Posts: 55Questions: 6Answers: 2

    My checkboxes came from Select extension and this code
    columnDefs: [ { orderable: true, className: 'select-checkbox', targets: 0 } ],
    select: { style: 'multi', selector: 'td:first-child' }

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    I possibly wasn't clear enough. Without a test case showing the issue I cannot offer any help to resolve this issue since I need to be able to debug it.

This discussion has been closed.