Hello, I have a dataset with a column colled id_Zone.
On my parameters I have listZone that have a listZone = 1,3
If my listZone is on dataset (column id_Zone), checkbox is True
Hello, I have a dataset with a column colled id_Zone.
On my parameters I have listZone that have a listZone = 1,3
If my listZone is on dataset (column id_Zone), checkbox is True
I would recommend using an expression structure binding, using both view.params.listZone
and view.params.listZoneBuilding
. You can then use a script transform to check if one is in the other.
Script Transform - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)
Your expression is on a boolean checkbox?
You're attempting to evaluate if an integer called list zone exists in the id_zone column?
convert the dataset column id_Zone into a list by,
TIP - Converting a dataset column into a list - Ignition - Inductive Automation Forum
compare if it is present in the listZone by,
any(map(lambda value: value in id_Zone, listZone ))
Thank you. here is the solution I have.
Don't post screenshots of code, post the code directly, surrounded in triple backticks:
```python
code
```
Here's how to rewrite your script more pythonically using @vasanth.p 's method:
listZoneBuilding = value['listBuildingZone']
listZone = value['listZone']
zoneIds = listZoneBuilding.getColumnAsList(x) # replace x with the column's index.
return any(map(lambda zone_id: zone_id in zoneIds, listZone))
As @pascal.fragnoud has shown there is a better way to write the transform. Also, there is a generic way to get the index from the column name.
listZoneBuilding = value['listBuildingZone']
listZone = value['listZone']
zoneIds = listZoneBuilding.getColumnAsList(listZoneBuilding.getColumnIndex('id_zone'))
return any(map(lambda zone_id: zone_id in zoneIds, listZone))
I think listZone
is supposed to be a list of ids, zone so you can't check it like that. That's why @vasanth.p suggested using map
.
Huh, some how I missed that.