gyrocode / jquery-datatables-checkboxes

Checkboxes is an extension for the jQuery DataTables library that provides universal solution for working with checkboxes in a table.
https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
MIT License
150 stars 61 forks source link

Missing checkbox checked status when checkboxes are rendered #138

Open WillYouth opened 2 years ago

WillYouth commented 2 years ago

Hi I wish to know how can I get my checkbox status when rendered checkboxes in table. I already create the table using html with checkbox status. But after initialize using this plugin, the checkbox status are all cleared.

Before: <input type="checkbox" name="items[]" checked="" value="312"> After: <input type="checkbox" class="dt-checkboxes" autocomplete="off">

Thanks a lot for the help

WillYouth commented 2 years ago

@exptom or @mpryvkin can help with this issue? Thanks!

halali commented 2 years ago

you can add selectCallback to your tabel. Something like this


                     checkboxes: {
                            selectRow: true,
                            selectCallback: function(nodes, selected){
                                console.log(nodes);
                                if(selected) {
                                    $('input[type="checkbox"]', nodes).prop('checked', true);
                                } else {
                                    $('input[type="checkbox"]', nodes).prop('checked', false);
                                }
                            }
                        }