Radio Buttons on a DataTable
Radio Buttons on a DataTable
pedrocsa
Posts: 9Questions: 1Answers: 0
Hi,
I am using a datatable with checkboxes on the first column that permit multiple selection.
But now, I need that this checkboxes permit only single selection or it can be used a radio button on it.
This is the link to show my page http://cursosites-com-br.stackstaging.com/suporte_datatables.php
Can someone help me?
Regards,
Pedro
This discussion has been closed.
Replies
Not sure if you are using the
select
extension. This select example uses checkboxes and allows multiple selections if you hold down shift or control. But if you changestyle: 'os'
tostyle: 'single'
then you can only select one row even if shift or control are used.https://datatables.net/extensions/select/examples/initialisation/checkbox.html
Kevin
I wasn't Kthorngren, but I tried to insert this on the code, but it still not working, I'm still being able of selecting multiple checkboxes...
The code for the datatable is written this way, check if I used the
select
extension right...Looked at your code and you are using the "checkboxes" plugin by gyrocode. I'm not sure if there is an option within that plugin to allow for only one row to be selected. There is this note in the docs:
https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
"If you’re using Select extension, you may want to enable multiple row selection using select.style option."
With this in the example:
Did you load the 'select' extension JS? If not you will need to load that and use the same example but change to this:
I haven't tried that with the checkboxes plugin but I think it should work.
Here is the docs for the
select
extension:https://datatables.net/extensions/select/
Kevin
Thank you Kevin!
I managed to find an example in the comments of the this link (https://www.gyrocode.com/articles/jquery-datatables-row-selection-using-checkboxes-and-select-extension/comment-page-3/#comments)
But I'll try to use checkboxes withtou the plugin, I didn't realize before that I was using an external plugin.
Best regards,
Pedro