I'm looking to change the value of a checkbox within a
DataGrid based on whether the item is selected or not. I don't
however want to add a selected field to the data as this is
metadata rather than data itself.
Can anyone advise me on how to reference the checkbox to
control and read its value based on row or item, without attaching
a data provider.
"...read its value based on row or item..." No, you cannot do
that because item renderers are recycled. Only the visible rows in
the list/dg even exist.
All item renderers MUST be data driven. If you do not want a
"selected" property in your underlying data, you could use the raw
data to build a special run-time arrayCollection of custom objects,
with the custom object class containing the "selected" property.
When you save the modified data, you strip out that property.
Another possibility would be to have some structure (like
associative array or dictionary) external to the GG, but accesible
to the renderers, that stores the value of the checkbox selected
property using a key. In the renderer, in the set data() override,
use the key in the current item to retrieve and store the checkbox
state value. then in commitProperties, set the checkbox selected
property to the stored value.