1 Reply Latest reply on Nov 20, 2006 9:23 AM by ntsiii

    Iam able to do delete,add,modify  using the following  Mxml application but these are not affecting to contactlist.xml 

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" width="500"
      height="600" >
      <mx:Model id="contact" source="datamodel/contactlist.xml"/>

      import mx.events.*;
      import mx.collections.*;
      import mx.utils.*;

      // Add a person to the ArrayCollection.
      public function addPerson():void {
      ac.addItem({first_name:firstInput.text, last_name:lastInput.text,

      // Remove a person from the ArrayCollection.
      public function removePerson():void {
      // Make sure an item is selected.
      if (dg.selectedIndex >= 0) {


      // Update an existing person in the ArrayCollection.
      public function updatePerson():void {
      // Make sure an item is selected.
      if (dg.selectedItem !== null) {
      ac.setItemAt({first_name:firstInput.text, last_name:lastInput.text,
      phone:phoneInput.text}, dg.selectedIndex);

      // The change event listener for the DataGrid.
      // Clears the text input controls and updates them with the contents
      // of the selected item.
      public function dgChangeHandler():void {
      firstInput.text = dg.selectedItem.first_name;
      lastInput.text = dg.selectedItem.last_name;
      phoneInput.text = dg.selectedItem.phone;

      // Clear the text from the input controls.
      public function clearInputs():void {
      firstInput.text = "";
      lastInput.text = "";
      phoneInput.text = "";

      // The labelFunction for the ComboBox;
      // Puts first and last names in the ComboBox.
      public function myLabelFunc(item:Object):String {
      return item.first + " " + item.last;

      source= ""/>

      <!-- The ArrayCollection used by the DataGrid and ComboBox. -->

      <mx:DataGrid width="450" id="dg" dataProvider="{ac}"
      <mx:DataGridColumn dataField="first_name" headerText="First Name"/>
      <mx:DataGridColumn dataField="last_name" headerText="Last Name"/>
      <mx:DataGridColumn dataField="phone" headerText="phone"/>

      <!-- Form for data to add or change in the ArrayCollection. -->
      <mx:FormItem label="First Name">
      <mx:TextInput id="firstInput"/>
      <mx:FormItem label="Last Name">
      <mx:TextInput id="lastInput"/>
      <mx:FormItem label="phone">
      <mx:TextInput id="phoneInput"/>

      <!-- Buttons to initiate operations on the collection. -->
      <mx:Button label="Add New" click="addPerson()"/>
      <mx:Button label="Update Selected" click="updatePerson()"/>
      <mx:Button label="Remove Selected" click="removePerson()"/>
      <!-- Clear the text input fields. -->
      <mx:Button label="Clear" click="clearInputs()"/>