3 Replies Latest reply on Mar 3, 2008 6:21 PM by ntsiii

    Editable Datagrid from programmaticaly built XmlListCollection help needed

    LordPathogen
      Hi, I am trying to build an editable datagrid with 20 empty rows in it. Users will fill out the cells, this then gets persisted to a DB, then later by making selections in a combobox, they can bring this data back for viewing and/or modification. I have been trying to create the XML dynamically and then addItem on the XmlListCollection to no avail. Can someone please point out where I am going wrong? Thanks!

      [Bindable] private var teamGridDataAsXml:XML;
      [Bindable] private var teamGridData:XMLListCollection;

      private function initEmptyTeamGrid():void {

      teamGridData = new XMLListCollection();
      var s:String = "<rows>";
      for(var i:int = 0; i < 20; i++) {
      s += "<row rowIndex=\'" + i + "\' agentId='' firstName='' lastName='' country='' />";
      }
      s += "</rows>";

      teamGridDataAsXml = new XML(s);
      teamGridData.addItem(teamGridDataAsXml);

      }

      <mx:DataGrid id="agentInfo" editable="true" dataProvider="{teamGridData}" width="100%" height="100%" rowCount="20">
      <mx:columns>
      <mx:DataGridColumn headerText="#" dataField="@rowIndex" editable="false"/>
      <mx:DataGridColumn headerText="Agent ID" dataField="@agentId" editable="true"/>
      <mx:DataGridColumn headerText="First Name" dataField="@firstName" editable="true"/>
      <mx:DataGridColumn headerText="Last Name" dataField="@lastName" editable="true"/>
      <mx:DataGridColumn headerText="Country" dataField="@country" editable="true"/>
      </mx:columns>
      </mx:DataGrid>