1 Reply Latest reply on Apr 22, 2010 7:14 AM by dakasadakasadaka

    delete item in datagrid with amfphp

    dakasadakasadaka

      hello,

      I'm trying to get the o_id of datagrid but can't find how to refference!

      hier is my datagrid:

      <mx:DataGrid width="100%" id="comments" dataProvider="{commentsCollection}">
                      <mx:columns>
            <mx:DataGridColumn headerText="Object ID" dataField="o_id"/>
                              <mx:DataGridColumn headerText="Object Name" dataField="o_name"/>
                              <mx:DataGridColumn headerText="Object Type" dataField="o_type"/>
            <mx:DataGridColumn headerText="Object Country" dataField="o_country"/>
                              <mx:DataGridColumn headerText="Object Place" dataField="o_place"/>
                              <mx:DataGridColumn headerText="Object Address" dataField="o_adress"/>
            <mx:DataGridColumn headerText="Object ZIP" dataField="o_postcode"/>
            <mx:DataGridColumn headerText="Object Nummer" dataField="o_nr"/>
            <mx:DataGridColumn headerText="Edit Object" dataField="o_nr">
            </mx:DataGridColumn>
            <mx:DataGridColumn headerText="Delete Object" dataField="o_nr">
             <mx:itemRenderer>
              <fx:Component> 
               <mx:LinkButton label="Delete" click="outerDocument.deleteItem(event)"/> 
              </fx:Component> 
             </mx:itemRenderer>
            </mx:DataGridColumn>
                      </mx:columns>
         </mx:DataGrid>

      and hier is my remoteObject

        <mx:RemoteObject id="GetOwnerObjects" source="ownerGetObjects" destination="amfphp"
          fault="faultHandler(event)" showBusyCursor="true">
         <mx:method name="getAllPosts" result="getAllPostsHandler(event)" fault="faultHandler(event)" />
         <mx:method name="sendComment" result="sendCommentHandler(event)" fault="faultHandler(event)" />
         <mx:method name="deleteObject" result="deleteHandler(event)" fault="faultHandler(event)" />
        </mx:RemoteObject>

      And hier is the actionscript that calls the amfphp:

      public function deleteItem(event:MouseEvent):void
        {        
         //GetOwnerObjects.removeItemAt(comments.selectedIndex);
        
         GetOwnerObjects.deleteObject(comments.selectedIndex);
         //GetOwnerObjects.removeItemAt(comments.selectedIndex);
         GetOwnerObjects.getAllPosts(); 

        } 
      public function deleteHandler(evt:ResultEvent):void
                  {
                   Alert.show("Deleted");
                  }

       

      ------------------Question-----------------------------------

      How can I refference to datagrid with o_id in actionscript?

      I tryied like this:

      GetOwnerObjects.deleteObject(comments.selectedIndex.o_id);

      But it didn't work!

      Any help would be great

      tnx,

      Daka