this is what i inherited and the context for my learning. go nuts. for the record: only the items in my folder have been created by myself and are not part of the project proper. just attempts to understand key concepts. everything else: the guy before me.
You'll probably need to share the embedded views as well.
See if this helps. Copy this JSON and paste it into a deep selected container.
[
{
"type": "ia.display.table",
"version": 0,
"props": {
"selection": {
"selectedColumn": "col1",
"selectedRow": 1,
"data": [
{
"col1": true
}
]
},
"columns": [
{
"field": "col1",
"visible": true,
"editable": true,
"render": "boolean",
"justify": "auto",
"align": "center",
"resizable": true,
"sortable": true,
"sort": "none",
"filter": {
"enabled": false,
"visible": "on-hover",
"string": {
"condition": "",
"value": ""
},
"number": {
"condition": "",
"value": ""
},
"boolean": {
"condition": ""
},
"date": {
"condition": "",
"value": ""
}
},
"viewPath": "",
"viewParams": {},
"boolean": "toggle",
"number": "value",
"progressBar": {
"max": 100,
"min": 0,
"bar": {
"color": "",
"style": {
"classes": ""
}
},
"track": {
"color": "",
"style": {
"classes": ""
}
},
"value": {
"enabled": true,
"format": "0,0.##",
"justify": "center",
"style": {
"classes": ""
}
}
},
"toggleSwitch": {
"color": {
"selected": "",
"unselected": ""
}
},
"nullFormat": {
"includeNullStrings": false,
"strict": false,
"nullFormatValue": ""
},
"numberFormat": "0,0.##",
"dateFormat": "MM/DD/YYYY",
"width": "",
"strictWidth": false,
"style": {
"classes": ""
},
"header": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
},
"footer": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
}
}
]
},
"meta": {
"name": "Table"
},
"position": {
"basis": "400px"
},
"custom": {},
"propConfig": {
"props.data": {
"binding": {
"type": "property",
"config": {
"path": "this.custom.ds"
}
}
},
"custom.ds": {
"binding": {
"type": "tag",
"config": {
"mode": "direct",
"tagPath": "[pckg_barrelwashline]_Testing/ds",
"bidirectional": true,
"fallbackDelay": 2.5
}
}
}
},
"events": {
"component": {
"onEditCellCommit": {
"type": "script",
"scope": "G",
"config": {
"script": "\tds = self.props.data\n\tds = system.dataset.setValue(ds, event.row, event.column, event.value)\n\tself.custom.ds = ds"
}
}
}
}
}
]
This is the tag I'm referencing:
Editing datasets is pretty trivial in Tables once you understand how they work; it was more editing SQL tables where I was talking about it being a bit painful, as then you're having to form the INSERT/DELETE/UPDATE statements
i just got in. i'll paste that code shortly.
i think that's kinda funny: to me, SQL is second nature and i wish they'd used a database for the transactions. but i think that might be the mental roadblock. i have to do a lateral shift.
EDIT: here's a more complete export:
CrossCountry_Development_2023-07-12_0710.zip (182.5 KB)
EDIT 2: copy/paste --> error. it's looking for [pckg_barrelwashline]_Testing/ds
, which i presume is the tag
you said you were referencing... but i'm not yet familiar enough with the dialogs to know where that is supposed to be built. but, again presuming, i could just make my own tag with a stack of booleans to meet the requirements, yes?
It is indeed, the only tag referenced inside of the provided JSON. He has setup a bidirectional tag binding on a custom property ds
.
That dataset, is then referenced in a property binding on props.data
.
You should be able to create your own dataset tag to use for testing and fix the reference in the tag binding to point to that tag.
okay. i followed advice and spent an afternoon with Ignition support. i learned a LOT. here's what i learned that's relevant to this topic in case someone else is dealing with this issue.
-
there is a BUG that prevents toggles and checkboxes from being one-shotted in dynamic tables. This bug's ID is IGN-1611. you can add a ticket to that bug ticket to be informed when it gets fixed. it absolutely sucks, but it's out of our hands for now.
-
when working with
booleans
, only onEditCellCommit will work. none of the other cell events will work withbooleans
. so that is why NONE of mysystem.perspective.print()
calls were working: they were never being fired. i had put all my code in theonEditCellStart
event. which ignoresboolean
values. as soon as i relocated the code: whabam! everything worked. -
the code to extract the toggle values turned out to be pretty straightforward, as i'd hoped. not knowing that the code was in the wrong event was driving me to drink and bashing all kinds of attempted workarounds. for completion purposes, find below the complete code, which is bound to the table, not the cells. the table's
data
prop is bound to the tag's datasetvalue
. it works like a charm (barring the two-click bug). and here's a screen-medley of what-goes-where:
the code below goes into the table's onEditCellCommit
event.
#
# grab all variables such as row index, column name, underlying dataset
#
selectedRow = self.props.selection.selectedRow
selectedCol = self.props.selection.selectedColumn
dataset = self.props.data # <--- or wherever you get your dataset from
#
# new value of the toggle button. takes existing value and NOTs it.
#
toggledValue = not dataset.getValueAt(selectedRow,selectedCol)
#
# alters a dataset by changing one value and recreating a new dataset
#
newDataset = system.dataset.setValue(dataset,selectedRow,selectedCol,toggledValue)
#
# write newly created dataset back to crosscountryassets dataset tag.
#
paths = ["[<PROJECT>]Users/<PATH_TO_DATASET>"] #<--- replace with your paths, &c
values = [newDataset]
system.tag.writeBlocking(paths, values)
thank you all so much for your help, your patience, and your advice. i hope this is of use to someone else wanting to do this kind of thing.