# Checkbox filter, selected box and non selected boxes

**URL:** <https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 12, 2024, 3:56pm UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754 "2024-06-12T15:56:49Z")\
**Posts on this page:** 9\
**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:** [June 12, 2024, 3:56pm UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/1 "2024-06-12T15:56:49Z")

</div>

Hello!

I´m applying a checkbox filter to a table binded to a named query.

I using a Expression

```python

chk_6: {.../Checkbox_inv_6.props.selected}
chk_7: {.../Checkbox_inv_7.props.selected}
chk_8: {.../Checkbox_inv_8.props.selected}
data: {this.custom.data}

```

to aply the checkboxes filter

with a transform filter

```python
def transform(self, value, quality, timestamp):
    output = []
    for row in value['data']:
        nivel = row['Nivel'] 
        if value['chk_6'] and nivel == 6:
            output.append(row)
        elif value['chk_7'] and nivel == 7:
            output.append(row)
        elif value['chk_8'] and nivel == 8:
            output.append(row)

            
    return output

```

how to do if i want chck\_7 and chk\_8 unselected

---

<div class="post-metadata">

**Author:** ![danieltalbot](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/danieltalbot/32/11201_2.png) [@danieltalbot](https://forum.inductiveautomation.com/u/danieltalbot)\
**Post date:** [June 12, 2024, 4:07pm UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/2 "2024-06-12T16:07:06Z")

</div>

You just want to check if value['chk\_7'] and value['chk\_8'] are false?

```python
def transform(self, value, quality, timestamp):
    output = []
    for row in value['data']:
        nivel = row['Nivel'] 
        if value['chk_6'] and nivel == 6:
            output.append(row)
        elif not value['chk_7'] and nivel == 7:
            output.append(row)
        elif not value['chk_8'] and nivel == 8:
            output.append(row)

            
    return output

```

---

<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:** [June 13, 2024, 7:59am UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/3 "2024-06-13T07:59:53Z")

</div>

, so it was right, just needed to change the check status, if i want to show chk\_5 items, Thanks!

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/8/f84b2e0d5db64b7624944376bd0b5bd97f926417.png)  
checked  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c5ee5d47788ec8bb6e66b6e29c6c17785eaf7ab9.png)  
not checked  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4bef66635c63181bf0a8395e649d0812a850570b.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/d/7d3651cdc2d828be86d0c6833918375a03159278.png)

```python

    output = []
    for row in value['data']:
        nivel = row['Nivel']
        if value['chk_5'] and nivel == 5:
            output.append(row)
        elif value['chk_6'] and nivel == 6:
            output.append(row)
        elif value['chk_7'] and nivel == 7:
            output.append(row)
        elif value['chk_8'] and nivel == 8:
            output.append(row)
    return output

```

---

<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:** [June 13, 2024, 9:15am UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/4 "2024-06-13T09:15:32Z")

</div>

So you have a data table, and checkboxes.  
On a table, you have a structure binding, bound to the table's data and your checkboxes.  
And you want to filter the data based on the checkboxes, to feed only certain rows to your table.

Did I get that right ?

---

<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:** [June 13, 2024, 9:25am UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/5 "2024-06-13T09:25:50Z")

</div>

Yep, right, now is working, but now I would like to do the same from a table column with checkboxes and I don´t know if I can aply the same logic

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/0/e053e4e2cf78b1a0bd5d6047977e33974535d4fa.png)

the checkbox column is this:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/d/6db5c58ead5989b089e4220649e885e995a7c17b.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:** [June 13, 2024, 9:40am UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/6 "2024-06-13T09:40:23Z")

</div>

I'm not sure what you're asking.  
Do you want show only the rows where `select` is in a specific state ?

That looks like something that should be filtered directly in a query if that's where the data comes from.

Otherwise, you can do

```python
return [row for row in value if row['selected']]

```

in a transform

---

<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:** [June 13, 2024, 10:37am UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/7 "2024-06-13T10:37:28Z")

</div>

> [@pascal.fragnoud](#):
>
> I'm not sure what you're asking.

If it's related to his previous question, which I can't find, I think the table in post #5 is acting as a dropdown multi-select and he's going to filter the main table on those selections. It might save a trip to the database but it looks very unwieldy for a user. Judging by the height of the scrollbar and the pager at the bottom, there are 90 options to choose 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:** [June 13, 2024, 10:38am UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/8 "2024-06-13T10:38:57Z")

</div>

Yes, that´s right, may options on the table with checkboxes to filter the other table, but there is no other way as the main table is huge and need to be filtered.

the main table already has a custom property wich I use to bind the named query

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/097218fecf9616e8c33567cf718f71a8c3ccbc17.png)

I aply the basic checkbox filter as @Transistor taught me

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

but now I would like to aply a filter for other data from a table with checkboxes if there is no a better way.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/7/9711c04cfecbb76fa5ea8fb7c1a49c5bd2d12583.png)

the table is already multiselect as I added the necesary script:

```python
def runAction(self, event):
	self.props.data[event.row][event.column] = event.value

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/a/6af12bdf2c1f5cdd65978bea3a79c5b55655b935.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:** [June 13, 2024, 11:33am UTC](https://forum.inductiveautomation.com/t/checkbox-filter-selected-box-and-non-selected-boxes/91754/9 "2024-06-13T11:33:13Z")

</div>

Options:

1. Give preset groups of likely combinations: `00` or `MAD` or `FINCI`, etc.? Your selection looks well organised so an easy way to do this would be have three dropdowns,

- Dropdown 1: `All, 00, 01, 02, etc.`
- Dropdown 2: `All, MAD, MAE, MAF, etc.`
- Dropdown 3: `All, FINCI, FINCU, FINDO, FINNU, etc.`

1. Use the table component's column filter. (This isn't very powerful and doesn't allow wildcards.)
2. Allow the user to create a pattern that could be used in an SQL "WHERE LIKE" clause. e.g.,  
`00-*-FINCI`  
`*-MAD-*`  
MySQL, for example, allows use of regular expressions with `REGEX_LIKE()` function, etc. [Tutorial](https://dev.mysql.com/doc/mysql-tutorial-excerpt/8.0/en/pattern-matching.html).  
You would need to be very careful to sanatise this so that SQL injection is not possible.
