Selecting all records in a server-side paginated table

  1. My goal: I have a “large” database (tens or hundreds of thousands of records) that I display in a table with server-sided pagination. I want to be able to select rowKeys that are not loaded and displayed in the table, for later bulk actions.

    Example: Let’s say I have a source table with 100k records, with server-side pagination and pageSize = 50. I apply certain server-side filtering to arrive at 10k records that I want to delete. I now want to be able to programmatically select all those 10k records to then delete them. I only want to include their IDs in selectedRowKeys, not load all their data

  2. Issue: There is no obvious way to select off-view records like this.

  3. Steps I've taken to troubleshoot: I tried the table.selectRow() method, with mode = “key” and key = a separate script that returns all the filtered IDs. However, it still only adds the visible records to the selectedRowKeys property. It is indeed possible to go page by page and manually add (many) IDs to the selection with persist selection, so I feel it should also be possible to do programmatically.

  4. Additional info: (Cloud or Self-hosted, Screenshots)

I think it depends on the exact usecase but I think I would add in a bulk actions button on the top right of the table and then having a custom built query to do bulk actions on all of the relevant data. and then, you could have a
delete all where status = archived

Hi David,

Thanks, but I’d like the records to actually be selected in the table, to then be able to do any sort of bulk action on them, for example delete them.

My current workaround is that I store the IDs in a variable (for later bulk actions), but not good from a UI perspective since those records are not “checked” in the table.

you should still be able to perform actions.

I would add a variable that is something like UNSELECTED_IDS and if a user unselects, it gets added to that var and if a user selects it gets removed

I would have a SELECT_ALL variable where if all rows in the table are selected, it sets to true (if selectedRows.length == tbl.pagination.length)

if SELECT_ALL == true –> on changing page select all rows EXCEPT the rows in UNSELECTED_IDS (make sure you have the index type set to the key using the id)

from there, I would have 2 different queries

if SELECT_ALL == true then have a SQL query that is Update all where id not in SELECTED_IDS

if SELECT_ALL == false then have a SQL query that is update all where id in tbl.SelectedSourceRows.id

hope that makes sense!

1 Like

Hi @axel.trolle,

Was. @DavidD's comment above helpful in resolving your issue?

I was curious about specifying your use case, are users actively clicking through 10k rows of records to delete? The process of mass deleting thousands of rows may be easier to do on the backend via SQL queries that take in some parameter from the user such as a start and end index for large chunks of consecutive rows.