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!
checked
not checked
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
the checkbox column is this:
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.
the table is already multiselect as I added the necesary script:
def runAction(self, event):
self.props.data[event.row][event.column] = event.value