Can a selector option be applied to a custom button

Can a selector option be applied to a custom button

bigracefan18bigracefan18 Posts: 15Questions: 2Answers: 0

I'm just wondering if it's possible to do something like this with a custom button.
buttons: [
text: "Set selection",
name: "DOESelect",
className: 'DOEcustom',
oSelectorOpts: { filter: 'applied', order: 'current', page: 'all' },
action: function ( e, dt, node, config ) {
setSelection("set", dt.column(0).data());
]

I always get the the full table rather than the filtered results. "setSelection" is an Ajax call. My other buttons all work fine with the filtered results.

Replies

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    I'm not familiar with oSelectorOpts but a quick search of the forum it looks like it might be a TableTools (old/retired extension) option. These examples show how to use row and column selectors with the Buttons extension:
    https://datatables.net/extensions/buttons/examples/print/select.html
    https://datatables.net/extensions/buttons/examples/print/columns.html

    Not sure they will apply to custom buttons though.

    I always get the the full table rather than the filtered results. . "setSelection" is an Ajax call.

    Are you trying to filter the data sent to this function in this statement?

    setSelection("set", dt.column(0).data());
    

    If so then use the selector-modifier in the column() parameters. Something like this dt.column(0, { filter: 'applied' }).data()).

    My other buttons all work fine with the filtered results.

    Are they using the built in export functionality or are they custom buttons?

    Kevin

  • bigracefan18bigracefan18 Posts: 15Questions: 2Answers: 0

    dt.column(0, { filter: 'applied' }).data()).
    you nailed it. Exactly what I was looking for. Thanks.

This discussion has been closed.