Checkbox filter, selected box and non selected boxes

Hello!

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

I using a Expression


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

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

You just want to check if value['chk_7'] and value['chk_8'] are false?

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
1 Like

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

image
checked
image
not checked
image


    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

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 ?

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

the checkbox column is this:
image

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

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

in a transform

1 Like

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!

1 Like

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

I aply the basic checkbox filter as @Transistor taught me

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

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

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

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.
    You would need to be very careful to sanatise this so that SQL injection is not possible.
1 Like