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?
rivaldid
Posts: 55Questions: 6Answers: 2
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.
This discussion has been closed.
Answers
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
It's not working because I guess the checking action is an ::after
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.
Have you looked at the select() plugin / extension? That might be of interest to you.
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
This recent commit made it possible. It will be included in the next release of the Select extension (in the next few days).
Allan
Still not working, the table don't got sorted clicking the column header upon the checkboxes column.
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
My checkboxes came from Select extension and this code
columnDefs: [ { orderable: true, className: 'select-checkbox', targets: 0 } ],
select: { style: 'multi', selector: 'td:first-child' }
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.