bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

Select all Checkbox and pagination

Open empouras opened this issue 4 years ago • 1 comments

I think that a good improvement/feature would be to get the "Select All" checkbox on a table with a pagination to actually be selecting all rows in the table and not just all the rows of the first page of the pagination. Without this, it is really annoying to select all rows in a table with a lot of pages in the pagination.

Thank you in advance. :)

You can see the issue even at the following example. Check the header checkbox (What I called "Select All" checkbox), navigate to page 2. Nothing is selected :)

Example: https://live.bootstrap-table.com/example/options/maintain-meta-data.html

empouras avatar Jan 22 '21 14:01 empouras

Here is an alternative while awaiting for this feature:

const table = $('#table').bootstrapTable({
    pagination: true,
    maintainMetaData: true, // false by default, you'd lost the selection by changing page
    // ... other configuration
    onCheckAll: () => {
        const field = "id"; // or whatever discriminant field you have
        const values = table.bootstrapTable('getData').filter((o) => !o.selected && !!o[field]).map((o) => o[field]);
        if (values.length) {
            table.bootstrapTable('checkBy', { field, values });
        }
    },
    onUncheckAll: () => {
        const field = "id"; // or whatever discriminant field you have
        const values = table.bootstrapTable('getData').filter((o) => o.selected && !!o[field]).map((o) => o[field]);
        if (values.length) {
            table.bootstrapTable('uncheckBy', { field, values });
        }
    },
});

pistou avatar Jan 08 '24 10:01 pistou