Select Buttons and checkboxes

Select Buttons and checkboxes

piccardpiccard Posts: 4Questions: 2Answers: 1
edited August 2017 in Free community support

Hello,
I would like to use the select-buttons, like described in https://datatables.net/extensions/select/examples/initialisation/buttons.html. While this works fine, I would like to also have checkboxes inside, like described in https://datatables.net/extensions/select/examples/initialisation/checkbox.html. My problem is now, that each of them works fine, but not in a combination. When i add the buttons like this:

            buttons: [
                'selectNone',
                {
                    extend: 'selectColumns',
                    'selector': 'td:not:first-child',
                    style: 'os'
                },
                {
                    extend: 'selectRows',
                    'style': 'multi',
                    'selector': 'td:first-child',
                    'className': 'selected-row selected',
                },
                {
                    extend: 'selectCells',
                    'selector': 'td:not:first-child',
                    style:    'os'
                },

none is working, but when I outsource select, like this:

            select: {
                'style': 'multi',
                'selector': 'td:first-child',
                'className': 'selected-row selected'
            },

checkboxes just work fine. Any idea how to solve this????

Thanx :-)

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    You can't have the select.selector option set to be td:first-child and still be able to select any cells other than the first column.

    Could you explain what it is that you are looking to do please?

    Thanks,
    Allan

  • piccardpiccard Posts: 4Questions: 2Answers: 1

    Hello,
    I would like to have checkboxes in the first row, but also be able to select column-, row- or cell-wise. Is that possible?
    Thank you,
    Andy

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Yes. What I would suggest is that you set up your table like the example where you can change the selection item - then add another column into the table for the checkboxes. Instead of used Select to control the checkboxes automatically, assign your own event listener for them which will call row().select(), so the row can be selected regardless of which item type is being selected from the buttons.

    Allan

This discussion has been closed.