# Selections on checkbox icon

**URL:** <https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [December 13, 2023, 8:03am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069 "2023-12-13T08:03:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohd\_Waqas](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Mohd\_Waqas](https://forum.inductiveautomation.com/u/Mohd_Waqas)\
**Post date:** [December 13, 2023, 8:03am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/1 "2023-12-13T08:03:43Z")

</div>

Here is the example , we have table wth check box icon view on table and I have a doubt like how when we select the checksboxex then particular row will selected..... and data in table coming from database table via named query.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/54bfa7fa03cb6a257be79881e25e6a124650d977.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 13, 2023, 8:13am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/2 "2023-12-13T08:13:36Z")

</div>

Not gonna work. I think the `selection` properties of the perspective table are read only... which mean you can't select something programmatically. Not with built-in ways.  
BUT, since everything is possible, there are alternatives. The simplest one is probably to maintain a list of ids corresponding to the selected rows, then you can do whatever you want with those ids.

What's your end goal ? What happens to the selected rows ?

---

<div class="post-metadata">

**Author:** ![Mohd\_Waqas](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Mohd\_Waqas](https://forum.inductiveautomation.com/u/Mohd_Waqas)\
**Post date:** [December 13, 2023, 8:15am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/3 "2023-12-13T08:15:30Z")

</div>

delete after selected rows

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 13, 2023, 8:40am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/4 "2023-12-13T08:40:36Z")

</div>

Delete from the database ?  
Then indeed, maintain a list of the records that need to be delete, then when the user clicks the delete button, use those in your query. Then use `refreshBinding` to update the table.

---

<div class="post-metadata">

**Author:** ![Mohd\_Waqas](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Mohd\_Waqas](https://forum.inductiveautomation.com/u/Mohd_Waqas)\
**Post date:** [December 13, 2023, 8:45am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/5 "2023-12-13T08:45:02Z")

</div>

we have done for the multiselection and deleton through buttoon .......my query is when we click selected check box then particular row will selected then action performed of deletion

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 13, 2023, 8:46am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/6 "2023-12-13T08:46:26Z")

</div>

You'll need to be more specific than that, because as it is I believe I already answered that question.  
edit: Actually you don't even need to maintain a list, just build it from the rows that have been selected when the button is clicked.  
Loop through your data and filter the ones where the checkbox is checked.

---

<div class="post-metadata">

**Author:** ![Mohd\_Waqas](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Mohd\_Waqas](https://forum.inductiveautomation.com/u/Mohd_Waqas)\
**Post date:** [December 13, 2023, 8:58am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/7 "2023-12-13T08:58:24Z")

</div>

how we implement through script can you give some idea on that?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 13, 2023, 9:20am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/8 "2023-12-13T09:20:27Z")

</div>

```python
items_ids = [row['id'] for row in table.props.data if row['selected']]

```

---

<div class="post-metadata">

**Author:** ![Mohd\_Waqas](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Mohd\_Waqas](https://forum.inductiveautomation.com/u/Mohd_Waqas)\
**Post date:** [December 13, 2023, 10:03am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/9 "2023-12-13T10:03:36Z")

</div>

could you give more info about script where to improve ......we have done script on button for mutiselection its work.....for above script you send me where and how we implement ?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 13, 2023, 10:21am UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/10 "2023-12-13T10:21:44Z")

</div>

If you want more info... You'll have to give more info.

> [@pascal.fragnoud](#):
>
> You'll need to be more specific than that,

---

<div class="post-metadata">

**Author:** ![Mohd\_Waqas](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Mohd\_Waqas](https://forum.inductiveautomation.com/u/Mohd_Waqas)\
**Post date:** [December 13, 2023, 1:09pm UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/11 "2023-12-13T13:09:24Z")

</div>

Likewise we have information that - we want to select the rows such that on clicking the checkbox, the table selection data should append and not on the row click. Thereafter i will delete the rows which are there in the table.selection.data on click of a button.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 13, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/12 "2023-12-13T13:12:29Z")

</div>

> [@Mohd\_Waqas](#):
>
> on clicking the checkbox, the table selection data should

This is not possible. You can only change the table's native row selection with its own click/shift-click/ctrl-click user interface. If you want checkboxes within each row to carry the selection information, you will need to maintain all of that selection information yourself. And disable the table's own selection feature.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 13, 2023, 1:27pm UTC](https://forum.inductiveautomation.com/t/selections-on-checkbox-icon/83069/13 "2023-12-13T13:27:34Z")

</div>

Again, don't use the built-in `selection.data`. If you're not using the built-in selection mechanism, then the built-in data will not reflect your selection.

I'll try to make it as clear as possible:  
Your table contains data. In each row, you have a checkbox. If you want to find the rows where the checkbox has been checked, just iterate over the data and, for each row, check if the box is checked. If it is, take the id of the row. This is what the code I posted previously does.

On the button's `actionPerformed` event, add a script that will look like this:

```python
selected_ids = [row['id'] for row row in table.props.data if row['selected']]
runQuery("delete_things", {'ids': selected_ids})

```

This is ONLY to give you an idea of where to go next, there are a few things wrong with this script, that you will have to fix yourself (or give us enough details so that we can be more specific):

- the table's path will need to match your actual table's path
- `row['id']` will need to be changed to whatever is used to identified records in your database table
- `row['selected']` will need to be changed to whatever your checkbox's column is
- `runQuery` is only a placeholder, as I don't know what mechanism you use run the query
