# Add checkbox column in Ignition Perspective to filter other column

**URL:** <https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 29, 2024, 10:10am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621 "2024-04-29T10:10:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 10:10am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/1 "2024-04-29T10:10:45Z")

</div>

Hi!

I would like to add a column with checkboxes on a table in perspective.

Later on I will use this checkboxes to filter another column.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 10:14am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/2 "2024-04-29T10:14:08Z")

</div>

- Add a boolean column to the table's `props.data`.
- `column.n.render : boolean`
- `column.n.boolean : checkbox`

Tip: don't delete and repost. Use the edit button on your first post.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 10:22am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/3 "2024-04-29T10:22:20Z")

</div>

I just added a column boolean checkbox but is not showing the checkboxes  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/0124ad78af7ab96578cb8f1ea54ecf262e0f3dc4.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/4/f41118340235c2bf2b88aebdd302e3bd54599957.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 10:39am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/4 "2024-04-29T10:39:47Z")

</div>

1. The data has to exist so you need a named column in `props.data`. You could generate this in your SQL:

```python
SELECT
    column0,
    column1,
    column2,
    column3,
    FALSE AS check
FROM ...

```

1. You need to name the column in the `field` property.  
 ![Checkbox field](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2f882c369ae950801051afbadbcedb8023a25723.png)

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 10:54am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/5 "2024-04-29T10:54:40Z")

</div>

Now just appear a 0  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7b9e8431c209f09ed37d2cec1607b631baf2baa5.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/6/66176c4f9b367e1d5eb85d4dbe81085fe57f0bd1.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 11:00am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/6 "2024-04-29T11:00:50Z")

</div>

OK, it looks like SQL is converting TRUE and FALSE to 1 and 0.  
Try this:

```python
SELECT
    column0,
    column1,
    column2,
    column3,
    'false' AS 'select'
FROM ...

```

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 11:03am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/7 "2024-04-29T11:03:55Z")

</div>

SELECT A.ASSET "text",  
0 "select",  
TO\_NUMBER(APA.PARENTASSET) "Zone",  
TS.ID\_SEDE AS "id"

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 11:10am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/8 "2024-04-29T11:10:29Z")

</div>

> [@Alejandro\_Alaco](#):
>
> SELECT A.ASSET "text",  
> 0 "select",

Shouldn't that be,

```python
SELECT A.ASSET AS 'text',
0 AS 'select',

```

Also, see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 11:15am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/9 "2024-04-29T11:15:31Z")

</div>

The query is ok, I just checking why checkboxes doesn´t appear... 🤔

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 11:20am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/10 "2024-04-29T11:20:48Z")

</div>

![Select check](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/6/66ea88ed4a220ed01080fe896712992901e1a88d.png)

The `field` property "check" does not match the column name "select".

("select" isn't a very good column name in SQL!)

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 11:24am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/11 "2024-04-29T11:24:30Z")

</div>

yes, still don´t get why check column is not showing and why select column does

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 11:27am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/12 "2024-04-29T11:27:51Z")

</div>

Because you don't have a 'check' column in your SQL. Look at `props.data` and I expect you will see a 'select' column and no 'check' column.

You need `columns.4.field : select`.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 11:42am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/13 "2024-04-29T11:42:02Z")

</div>

Is working, but now can´t check the checkboxes as they all have value "0" I guess I will need to add some script

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/6/c6bb5207bc0a981bbcf6077ab96a480f76b87b7a.png)

Cheers

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 11:44am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/14 "2024-04-29T11:44:45Z")

</div>

`column.4.editable : true`

Yes, you will need to write code.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 11:50am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/15 "2024-04-29T11:50:05Z")

</div>

Ok, I will add based on previous code something like:

```python

# Assuming this script is triggered by an onClick event from a table component
# `event` is the object that contains details about the event that was triggered
if event.button == 1: # Check if the left mouse button was clicked
    # Get the selected row index
    selectedRow = self.props.selection.selectedRow
    
    if selectedRow is not None: # Ensure there is a selected row
        # Accessing the table's data
        data = self.props.data
        
        # Check if the selected zone is within the user's allowed zones
        if data[selectedRow]['Zone'] in system.util.getGlobals().get('userZones', []):
            # Get current state of the 'select' checkbox
            currentSelectValue = data[selectedRow]['select']
            
            # Toggle the value
            newValue = 0 if currentSelectValue == 1 else 1
            
            # Update the 'select' column in the data
            # Make a deep copy of the data to modify it
            import copy
            newData = copy.deepcopy(data)
            newData[selectedRow]['select'] = newValue
            
            # Set the modified data back to the table
            self.props.data = newData

```

But don´t know where to add it, on the column itself?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 11:57am UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/16 "2024-04-29T11:57:53Z")

</div>

No, to change the checkbox in run mode you have to edit the cell. The default is,  
`cells.allowEditOn : double-click`.  
You might prefer,  
`cells.allowEditOn : single-click`.  
Then click the checkbox.

You only need code to update your database or whatever you want to do.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 12:01pm UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/17 "2024-04-29T12:01:51Z")

</div>

See also:

> [@Editing Perspective table with allowEditOn single-click still takes two clicks](https://forum.inductiveautomation.com/t/editing-perspective-table-with-allowediton-single-click-still-takes-two-clicks/30446):
>
> I have a table with two columns that are editable, a boolean and a string. I set the onCellEdit field to “single-click” however the real functionality seems to be click once to select the row, then click again to check the boolean or start writing to the text column. Is there a way to make it truly be like a work on a single click? I tried to use the onFocus and onRowclick but nether tell me what column was clicked, which would be enough for me to then programatically just select the box. An…

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 12:06pm UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/18 "2024-04-29T12:06:27Z")

</div>

Ok thanks, and now where should add my on click script?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 29, 2024, 12:08pm UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/19 "2024-04-29T12:08:32Z")

</div>

It depends what you want to do.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [April 29, 2024, 12:10pm UTC](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621/20 "2024-04-29T12:10:57Z")

</div>

I would like to filter another table (table-1) with same 1st table depending on wich checkbox from (table-2) I click

[Next page](https://forum.inductiveautomation.com/t/add-checkbox-column-in-ignition-perspective-to-filter-other-column/89621.md?page=2)
