How to have all checkboxes checked by default?

How to have all checkboxes checked by default?

jtr1812jtr1812 Posts: 11Questions: 4Answers: 0

Hi,

I have a datatable using checkbox extension below and it works perfectly. However, I would need to have all checkboxes check when the datatable is initialized? Is it possible to do so? Is there easy function/method that I can use to get this?

I have the following code:

                    var myTable = $('#mytable').DataTable({
                      'data': result,
                      'paging': false,
                      'searching': false,
                      'columns': [
                         {
                            'data': 'ID',
                            'checkboxes': {
                              'selectRow': true
                            }
                         },
                         { 'data': 'Part_Number' },
                         { 'data': 'Part_Description' },
                         { 'data': 'Part_Type' },
                         { 'data': 'Part_Quantity' },
                         { 'data': 'Part_Price',
                           'render': $.fn.dataTable.render.number( ',', '.', 2, '$' )}
                      ],
                      'select':{
                            'style':'multi'
                        },
                      'order': [[1, 'asc']],
                    });

Thanks

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Checkboxes isn't ours, it's from Gyrocode, but I imagine it would work the same if you select all the rows (with rows().select() ) in initComplete, see here,

    Colin

  • jtr1812jtr1812 Posts: 11Questions: 4Answers: 0

    Yes, it works. Thanks very much.

This discussion has been closed.