There seems to be no equivalent of
extend: "selectedSingle"
to enable a button only if more than one row is selected. I'm guessing there's a work-around, but I haven't figured it out.
This question has an accepted answers - jump to answer
I haven't used that option but I have used something like this example: https://datatables.net/extensions/buttons/examples/api/enable.html
Kevin
But in that example, selecting one row enables both buttons. I want at least two rows to be selected to enable a particular button.
How about if you change:
table.button( 0 ).enable( selectedRows === 1 ); table.button( 1 ).enable( selectedRows > 0 );
To:
table.button( 1 ).enable( selectedRows > 1 );
This will enable button 1 when 2 or more rows are selected and disable if less than 2 are selected.
Yup - what Kevin says. You'd need your own buttons.buttons.init function here, which would add an event listener that checks the number of rows selected.
buttons.buttons.init
This is the code that Select uses for its selection event handler.
Allan
Thank you both! Up, up and away....
It looks like you're new here. If you want to get involved, click one of these buttons!
Answers
I haven't used that option but I have used something like this example:
https://datatables.net/extensions/buttons/examples/api/enable.html
Kevin
But in that example, selecting one row enables both buttons. I want at least two rows to be selected to enable a particular button.
How about if you change:
To:
This will enable button 1 when 2 or more rows are selected and disable if less than 2 are selected.
Kevin
Yup - what Kevin says. You'd need your own
buttons.buttons.init
function here, which would add an event listener that checks the number of rows selected.This is the code that Select uses for its selection event handler.
Allan
Thank you both! Up, up and away....