SelectAll Button - Select only rows filtered with SearchPanes or SearchBuilder

SelectAll Button - Select only rows filtered with SearchPanes or SearchBuilder

schwaluckschwaluck Posts: 103Questions: 27Answers: 1

Hello all,

I encountered the following problem today:

When I use SearchPanes or SearchBuilder to filter my table, it works fine. But afterwards I want to select all filtered entries to export them.
But when I use the "selectAll" button, it ignores my filter and just selects all entries from the table.

Is there a better solution for this?
In my case, it is necessary that the individual entries, which was filtered before, are selected. But if there are several hundred entries, a manual selection would be too time-consuming.

Following post only solved the problem if you used the search function:
https://www.datatables.net/forums/discussion/comment/47085

But this should not be used. Only Searchpanes and SearchBuilder.

Thanks a lot!
Schwaluck

This question has an accepted answers - jump to answer

Answers

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

    See this eexample for selecting the rows to export. If you want to export the remaining rows after searching use the selector-modifier of {search: "applied"}. You don't need to select them, unless you want to for other reasons.

    Kevin

  • schwaluckschwaluck Posts: 103Questions: 27Answers: 1

    Hi kthorngren,

    thank you for your quick response. Unfortunately, that doesn't solve my problem properly. Because yes, I sometimes want to export all entries at once, but sometimes only a handful of the filtered ones and if I understood the docs correctly, the setting (selected: null) would result in all entries always being selected for export after filtering, right?

    So the SelectAll button would be perfect if it would only select the filtered entries in the table.

    Do you have any idea how I can adjust the selectAll Button to achieve this?

    Thanks and best regards
    schwaluck

  • kthorngrenkthorngren Posts: 21,178Questions: 26Answers: 4,923
    Answer ✓

    The selectAll docs state this:

    The selectAll button will simply select all items in the table

    To export the filtered rows you would do something like this:

                    exportOptions: {
                        modifier: {
                            search: "applied"
                        }
                    }
    

    Kevin

  • schwaluckschwaluck Posts: 103Questions: 27Answers: 1

    Hey Kevin,

    I found the solution that worked for me:

            buttons: [
        
                { extend: "create", editor: editor, className: 'createButton' },
                { extend: "edit",   editor: editor, className: 'createButton' },
                { extend: "remove", editor: editor, className: 'createButton' },
                "selectNone",
                {
                text: 'Alle Auswählen',
                action: function () {
                table.rows( {search:'applied'} ).select();
                }
                },
            ]
    

    Thank you anyway! :)

    Best regards
    schwaluck

This discussion has been closed.