4 Replies Latest reply on Jul 29, 2009 10:29 PM by GG_81

    Unable to add or delete the datagrid row dynamically when dataprovider taken as XMLList

    GG_81

      Hi,

          I using XMLList as the dataprovider for the datagrid. While clicking on the linkbutton for adding or deleting, unable to perform the operation. I'm sending you the snippet of code for deletion. Please provide me addition code for row. Deletion code is not working, please let me know or do the changes in the code, what the main issue is??

       

      Code Snippet

       

      <mx:Script>
          <![CDATA[
                 
                    public function deleteItem(event:MouseEvent):void{
                      linkedSetData.removeItemAt(linkSet.selectedIndex);
                      linkedSetData.refresh();
              }
          ]]>
      </mx:Script>

       

      <mx:XMLList id="linkedSetData">
          <screens>
              <IPservicename>Data1</IPservicename>
              <IPparameter>Parameter-2</IPparameter>
              <statement>sets data to</statement>
              <OPservicename>Data2</OPservicename>
              <OPparameter>Parameter-1</OPparameter>
          </screens>
         
          <screens>
              <IPservicename>Data2</IPservicename>
              <IPparameter>Parameter-1</IPparameter>
              <statement>sets data to</statement>
              <OPservicename>Data1</OPservicename>
              <OPparameter>Parameter-2</OPparameter>
          </screens>

       

      </mx:XMLList>


      <mx:DataGrid id="linkSet" width="95%" dataProvider="{linkedSetData}" textAlign="center" resizableColumns="true">
                          <mx:columns>
                              <mx:DataGridColumn headerText="Service Name" dataField="IPservicename"/>
                              <mx:DataGridColumn headerText="Parameters" dataField="IPparameter"/>
                              <mx:DataGridColumn headerText="" dataField="statement"/>
                              <mx:DataGridColumn headerText="Service Name" dataField="OPservicename"/>
                              <mx:DataGridColumn headerText="Parameters" dataField="OPparameter"/>
                              <mx:DataGridColumn headerText="">
                                  <mx:itemRenderer>
                                      <mx:Component>
                                          <mx:HBox paddingTop="2">
                                              <mx:Spacer width="15%"/>
                                              <mx:LinkButton icon="@Embed(source='../resources/delete.png')" toolTip="Delete" click="outerDocument.deleteItem(event)"/>
                                          </mx:HBox>
                                      </mx:Component>
                                  </mx:itemRenderer>
                              </mx:DataGridColumn>
                          </mx:columns>
                      </mx:DataGrid>
                  </mx:Panel>   

       

       

      Thanxs

       

      Gaurav