0 Replies Latest reply on Oct 8, 2010 6:59 PM by mgargiullo

    Adding a button in an Advanced Data Grid that calls a AS function


      I'm having a bit of trouble with this... maybe I'm missing something elementary.


      I have a data grid that populates.  I'd like to make the first column that currently displays the an ID display a button that executes a function that acts on the passed ID.


      I can get the button to display, but when I click it, I get an error:


      ReferenceError: Error #1069: Property userlistDeleteUserFunc not found on Main and there is no default value.

      at userGrid/__lblData_click()[C:\Users\Mike\\src\userGrid.mxml:7]


      So the grid looks like this:



      <script tags...>


      private function userlistDeleteUserFunc(id:Number):void{




      </script tags>


      <mx:AdvancedDataGrid x="10" y="12" id="userlistgrid" width="808" height="348" dataProvider="{userlistdata}" selectionMode="multipleCells" editable="true" enabled="true" sortableColumns="true">


      <mx:AdvancedDataGridColumn width="90" dataField="id" headerText=" " editable="false" />

      <mx:AdvancedDataGridColumn headerText="Username" dataField="username" editable="false"/>

      <mx:AdvancedDataGridColumn headerText="Last Name" dataField="last" editable="true"/>

      <mx:AdvancedDataGridColumn headerText="First Name" dataField="first" editable="true"/>

      <mx:AdvancedDataGridColumn headerText="Email Address" dataField="email" editable="true"/>

      <mx:AdvancedDataGridColumn headerText="Phone" dataField="phone" editable="true"/>



      <mx:AdvancedDataGridRendererProvider dataField="id" renderer="userGrid" columnIndex="0" />






      And the renderer:




      <?xml version="1.0" encoding="utf-8"?>

      <s:MXAdvancedDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"




      <s:Label text="{data.id}"/>

      <s:Button id="lblData" top="0" left="0" right="0" bottom="0" label="Delete" click="{parentApplication.userlistDeleteUserFunc(data.id)}" />