Closed shanakaperera closed 3 years ago
I face the same problem. I need to use select style os
, but checkbox behaviour is broken in this case.
I created a JSFiddle to show the error: https://jsfiddle.net/nfzvgy3u/
@diesl, thanks for the example.
I don't see a problem here. Checkboxes extension inherits selection style used by Select extension. According to the Select extension documentation:
Operating system (
os
) style - where a single click will select a single item only, deselecting any others that were previously selected, a shift click will select a range of items and a ctrl / cmd click will add and remove items from the selection.
These keys work for me when working with multiple selections when style
is set to os
, i.e. holding ctrl key and clicking the rows will allow to select multiple rows.
It would be impossible now to have Select extension use style
set to os
and have Checkboxes extension behave as in multi
selection style.
In general I agree with you and everything works as intended as you describe it. However, when looking specifically at the checkbox itself, the behaviour feels unnatural for me.
Consider you have some rows selected and then
Currently this is not possible and clicking the checkbox selects this row alone.
I have to admit that that DataTables does not handle this "correctly" (imho) too, but maybe it is limited by the pseudo CSS implementation of the checkboxes. Speaking of os
, Windows Explorer can handle the described scenario.
Checkboxes implements the selection differently by using real checkboxes, so my impression was that a different and more "correct" behaviour/implementation would be possible.
@diesl I understand your case and you're right, it might be useful. I tried Windows Explorer with "Item check boxes" option enabled and it behaves like you described.
This is not currently possible but I will see what can be done.
@mpryvkin Wow, thanks for the quick implementation 👍
For reference, I posted the same question to DataTables Forum about implementation in native select extension: https://datatables.net/forums/discussion/68796/select-style-os-and-behaviour-of-checkbox
Thanks for the link. I wasn't aware of the style: 'multi+shift'
option which is another alternative solution to this problem.
Below shows my datatable code so far :
I have included your plugin into my table and it is seems to be working fine. But there is a very small problem that does satisfy my need. I don't want to set the table select style to multi since I am using row selection for loading data into another form. So the multi selection behavior does not meet my requirement here. But I need your checkbox selection method to delete data from the table. Maybe all the rows from the table . In that case, selecting the checkbox in the column header works fine. But when I try to select required check-boxes which are related to the rows I am willing to delete, multi-selection cannot be achieved. Previously selected checkbox is unchecked.
Any suggestions for resolve this issue would be grateful.