8 Replies Latest reply on Feb 2, 2007 12:15 PM by darko.romanov

    Problem in DataGrid

    darko.romanov
      hi all, I'm having this trouble. I have a datagrid and I'd like to have a button in every row that when clicked, they call a function of mine. So I wrote this:

      <mx:Script>
      <![CDATA[
      code...
      public function modifyProduct(id:String):void
      {
      Alert.show("Eliminare il prodotto "+id+"?");
      }

      ecc...
      <mx:Script/>
      ecc...

      mx:DataGrid x="10" y="123" width="717" height="351" dataProvider="{getProducts.lastResult.products.product}" id="productlist">
      <mx:columns>
      columns....
      <mx:DataGridColumn headerText="Categoria" dataField="category"/>
      <mx:DataGridColumn width="20">
      <mx:itemRenderer>
      <mx:Component>
      <mx:Button width="30" height="25" label=""
      click="modifyProduct(data.id)"
      icon="@Embed(source='images/modify.gif')"/>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>

      but I get this error:

      Call to a possibly undefined method modifyProduct

      How can I do this, in other ways?

      Thannks