0 Replies Latest reply on Jul 19, 2011 3:17 AM by Venkatesan Balasubramanian

    Error while saving dynamic row values of datagrid with record.

    Venkatesan Balasubramanian Level 1

      hi friends,

       

      i am trying to add dynamic row in datagrid and save that value with record.i succeeded in first part while i am saving the record the error show like this.

       

       

      errro:Property fromAmount not found on com.ci.view.Task and there is no default value.

      how i resolve this error.

       

      any suggession welcom

      thanks in advance.

       

      B.venkatesan


      code:


      package:

      package com.ci.view
      {
          [Bindable]
          public class Task
          {
              public function Task(frmAmount:String,toAmount:String,commissionPercentage:String)
              {
                  this.frmAmount=frmAmount;
                  this.toAmount=toAmount;
                  this.commissionPercentage=commissionPercentage;
              }
              public var frmAmount:String;
              public var toAmount:String;
              public var commissionPercentage:String;
          }
      }

      main mxml:

      [Bindable]
                  private var tasks:ArrayCollection;
                  private static const ADD_TASK:String= "";
                 
                  private function init():void
                  {
                      tasks = new ArrayCollection();
                      tasks.addItem(new Task("0","1000","0"));
                      tasks.addItem({frmAmount:ADD_TASK});
                  }   
                  private function checkEdit(e:DataGridEvent):void
                  {
                      // Do not allow editing of Add Task row except for
                      // "Click to Add" column
                      if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
                          e.preventDefault();
                  }
                  private function editEnd(e:DataGridEvent):void
                  {
                      // Adding a new task
                      if(e.rowIndex == tasks.length - 1)
                      {
                          var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                          var txtIn1:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                          var txtIn2:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                          var dt:Object = e.itemRenderer.data;
                         
                          // Add new task
                         
                          if((txtIn.text) != ADD_TASK)
                          {
                              var x:String=String(txtIn.text);
                          
                              tasks.addItemAt(new Task("", "", ""), e.rowIndex);
                          }
                         
                          // Destroy item editor
                          commPlanDetGrid.destroyItemEditor();
                         
                          // Stop default behavior
                          e.preventDefault();
                      }
                  }