3 Replies Latest reply on Apr 24, 2009 9:01 AM by ntsiii

    Accessing button properties in datagrid row?




      I ve a datagrid which has a button in each row called "Select". When the user clicks the button it calls a function which saves the row details in an array. I also want to change the label and icon of the button but don't know how to access it?


      I ve tried giving each button a unique ID but I "is not a valid identifier" so I m really not sure how to access each button from my main script, anyone help?


      Cheers in advance



        • 1. Re: Accessing button properties in datagrid row?
          Gregory Lafrance Level 6

          The click method can be defined in a <mx:Script> block outside the DataGrid and referenced with outerDocument.myFunc(), ensure it is public, not private.


          Change the label and icon by affecting the data in a collection.

          • 2. Re: Accessing button properties in datagrid row?
            shaunperry Level 1



            Thanks for replying, I m still unsure of how to access the properties of a button in a row? I currently have the code below and am struggling to access the properties of the 'Add' button so I can change the label and icon?







                                        <mx:DataGridColumn headerText="Group" dataField="groupName" width="130" editable="false" sortable="false" />
                                        <mx:DataGridColumn headerText="Article Number" dataField="articleNumber" width="200" editable="false" sortable="false" />
                                        <mx:DataGridColumn headerText="Article Name" dataField="slideTitle" width="230" editable="false" sortable="false" />
                                        <mx:DataGridColumn headerText="Colourway" dataField="colourway" width="218" editable="false" sortable="false" />
                                        <mx:DataGridColumn editable="false" paddingLeft="5" sortable="false">
                                                        <mx:Button label="Add" icon="@Embed(source='assets/icons/add.png')">
            • 3. Re: Accessing button properties in datagrid row?
              ntsiii Level 3

              Item renderers are "recycled".  Whenever the underlying data changes, or when you scroll, the visible ui elements are re-populated with the new underlying item data.


              This means that any part of an item renderer that is row dependent, that is, needs to be different for different rows, must be driven by values in the dataProvider item.


              So you will never want to get a reference to a button in a renderer, it will not do you any good.


              Instead, in your button renderer, update a property on the dataProvider item that controls the appearance of the button, and link the button's UI to that property.


              Actually, because they are tightly integrated with the framework to optimize performance, interactive itemRenderers are a bit difficult.  I advise you find an example(there are many) that is close to what you want and modify it.


              Tracy Spratt