Using Select with Buttons not working correctly

Using Select with Buttons not working correctly

Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

I am attempting to combine the 'Select' and 'Buttons' extensions in a simple way to allow me to have a checkbox in the first column and the buttons; copy, print, pdf, etc... above. Previously when I used TableTools if I select 1, 2, 3, etc... rows then only the selected rows would be copied, printed, etc.... Now, using 'Buttons', every row in my table is included no matter what rows I have actually selected.

The selection is working because my table is showing, for example, "Showing 1 to 3 of 3 entries 2 rows selected".

Any idea why this could be failing? Select works and Buttons works but not together?

I am happy to send a link via a PM.

Cheers

Chris

Answers

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Hi Chris,

    With buttons you need to tell it that you want it to export only selected rows. The buttons.buttons.exportOptions parameter is used for this. It is an object that is passed through to the buttons.exportData() method to get the data from the table.

    In this case,t he rows option is the one you want to use - specifically the selected parameter (row-selector).

    For example:

    {
      extend: 'pdf',
      exportOptions: {
        rows: { selected: true }
      }
    }
    

    Allan

  • Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

    Hi Allan,

    Thanks for the answer. How do I set a default value though, i.e. if no rows are selected then export all data and if X number of rows are selected just export those?

    Thanks

    Chris

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Hi Chris,

    Good question. There is no option for that at the moment unfortunately. Let me have a think about the best way of presenting such an option.

    Allan

  • Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

    Okay many thanks, hope you can come up with a solution!

This discussion has been closed.