Multiple selection passed to server action
Multiple selection passed to server action
Oleg2024
Posts: 1Questions: 1Answers: 0
I just started with this component. Your examples are missing a pretty common use-case: Create a table with multiple selection checkboxes, and a button to trigger following action: Get ID filed of all selected rows, create comma-separated string from them called “selection” and pass it as a parameter - redirect to some server action. Can you please create such an example?
Answers
Client-side, it is fairly trivial - use
rows().ids()
with a selector to get only the selected rows (assuming you are using the Select extension for DataTables:Then you can send to the server to do whatever you want with it.
If you don't have an id property for the table (
rowId
), then you can get any data point you want from a row using thepluck()
method:You may wish to do this in a custom button, if you are already using the Buttons extension, but equally, you can use any event you want on the page to do that.
Allan