2 Replies Latest reply on Feb 25, 2008 2:45 AM by neilpmas

    Referencing checkboxes in datagrid


      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.

        • 1. Re: Referencing checkboxes in datagrid
          ntsiii Level 3
          "...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.

          • 2. Re: Referencing checkboxes in datagrid
            neilpmas Level 1
            Thanks Tracy.