# Slate Table Widget: set selectedRowKeys property

**URL:** <https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553>\
**Category:** Ask the Community\
**Tags:** slate\
**Created:** [October 15, 2024, 3:30pm UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553 "2024-10-15T15:30:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![iirteza](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@iirteza](https://community.palantir.com/u/iirteza)\
**Post date:** [October 15, 2024, 3:30pm UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/1 "2024-10-15T15:30:35Z")

</div>

For the Slate table widget, I have pagination enabled. I want to create a checkbox to select every row on the page.

Ideal behaviour: (1) user may select one or two rows on a page, then (2) if they choose to, select all rows on the page by toggling a checkbox.

Overriding `selectedRowKeys` on the Slate Table widget config creates circular dependencies, and doesn’t allow user to do (1).

Any ideas?

---

<div class="post-metadata">

**Author:** ![gpirindev](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gpirindev](https://community.palantir.com/u/gpirindev)\
**Post date:** [October 21, 2024, 2:12pm UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/2 "2024-10-21T14:12:45Z")

</div>

If you create a checkbox via the html widget, or a button widget, you can create events on click. You could indeed overwrite `selectedRowKeys` on the Slate Table widget config with a variable holding the state, e.g. called `v_selection`, and:

- update `v_selection` when the checkbox/button is clicked
- update `v_selection` when a selection is made, e.g. on `selectedRowKeys.changed` event.  
You may also need to handle the “selected page” state as updating the selected rows may some times redirect you to page 1.

This could yield a complex setup across functions, events and variables. A cleaner approach may be to use the Code Sandbox widget to create a custom table where you handle the selection logic.

---

<div class="post-metadata">

**Author:** ![mai125](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mai125](https://community.palantir.com/u/mai125)\
**Post date:** [October 22, 2024, 10:10am UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/3 "2024-10-22T10:10:37Z")

</div>

thank you for the suggestions! do you have any tips on how we can handle the selected page not to reset to 1?

---

<div class="post-metadata">

**Author:** ![gpirindev](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gpirindev](https://community.palantir.com/u/gpirindev)\
**Post date:** [October 22, 2024, 1:23pm UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/4 "2024-10-22T13:23:34Z")

</div>

You can add a `currentOffset` field to `v_selection` , e.g.

```auto
v_selection = {
  "selectedRowKeys": [],
  "currentOffset": 0
}

```

and update it when a selection is made or when the checkbox/button to select all items on the page is clicked.

You can then set the currentOffset field in the raw widget json to  
`"{{v_selection.currentOffset}}"`

Here is an example widget json

```json
{
  "clickEvents": [],
  "columnData": "{{f_data}}",
  "columnOptions": {
    "key": {},
    "value": {}
  },
  "columnOrder": [
    "key",
    "value"
  ],
  "gridOptions": {
    "enableSelection": true,
    "pagingOptions": {
      "currentOffset": "{{v_selection.currentOffset}}",
      "pageSize": 2
    },
    "selectionOptions": {
      "checkbox": true,
      "multiSelect": true,
      "selectionRequired": false
    }
  },
  "selectedRowKeys": "{{v_selection.keys}}",
  "selectionIdentityColumnId": "key",
  "serverEnabled": false,
  "tooltipsEnabled": false
}

```

---

<div class="post-metadata">

**Author:** ![gpirindev](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gpirindev](https://community.palantir.com/u/gpirindev)\
**Post date:** [October 22, 2024, 1:31pm UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/5 "2024-10-22T13:31:30Z")

</div>

For example, if your table widget is called `w_table` with key column called `key` and your button is `w_select_all`, you can set the following event-action pairs:

1. w.table.selectedRowKeys.changed → v\_selection.set

```js
const currentlySelectedKeys = {{slEventValue}}

return {
    "keys": currentlySelectedKeys,
    "currentOffset": {{w_table.gridOptions.pagingOptions.currentOffset}}
}

```

1. w\_select\_all.click → v\_selection.set

```js
const currentOffset = {{w_table.gridOptions.pagingOptions.currentOffset}}
const pageSize = {{w_table.gridOptions.pagingOptions.pageSize}}
const all_keys = {{w_table.columnData.key}}
const all_keys_on_page = all_keys.slice(currentOffset, currentOffset + pageSize)

return {
    "keys": updatedKeys,
    "currentOffset": {{w_table.gridOptions.pagingOptions.currentOffset}}
}

```

Note that when changing the page, the selection state will not change and you will have to handle that case separately, if needed.

---

<div class="post-metadata">

**Author:** ![mai125](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mai125](https://community.palantir.com/u/mai125)\
**Post date:** [October 23, 2024, 9:02am UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/6 "2024-10-23T09:02:32Z")

</div>

Thank you for the very detailed explanations! Would it be possible to have the `currentOffset` exposed to Slate. Currently, it’s not possible to access it

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/system/32/3_2.png) [@system](https://community.palantir.com/u/system)\
**Post date:** [March 26, 2025, 11:03am UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/7 "2025-03-26T11:03:25Z")

</div>

Automatically bumped on March 26, 2025, 11:03am UTC



---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/system/32/3_2.png) [@system](https://community.palantir.com/u/system)\
**Post date:** [November 22, 2025, 6:24pm UTC](https://community.palantir.com/t/slate-table-widget-set-selectedrowkeys-property/1553/8 "2025-11-22T18:24:25Z")

</div>

Automatically bumped on November 22, 2025, 6:24pm UTC


