2 Replies Latest reply on Jun 19, 2007 2:17 PM by ntsiii

    datagrid columns

    Level 7
      public function addDataRow():void{
      //acPrice = new ArrayCollection;
      var tempObj:Object = new Object();
      tempObj.priceid = 0;
      tempObj.estimateid = 0;
      tempObj.qty = 0;
      tempObj.perpiece = 0;
      tempObj.per1000 = 0;
      tempObj.setupfee = 0;
      tempObj.total = 0;

      acPrice.addItemAt(tempObj, price_dg.selectedIndex + 1);

      this.price_dg.dataProvider = acPrice;
      this.price_dg.editable = true;
      }

      Hi All,
      This is my function to add a line on my datagrid. I want to create a generic
      function like
      public function addDatagridRow(columns:???, myArray:ArrayCollection,
      myDataGrid:String):void{
      var tempObj:Object = new Object();
      ??????
      myArray.addItemAt(tempObj, myDataGrid.selectedIndex + 1);

      myDataGrid.dataProvider = myArray;
      myDataGrid.editable = true;
      ???
      }
      How can I get automatic all the columns from my dataGrid?
      How can I get each column to setup myTempObj?
      How can I set the focus in the added row , left column of my datagrid?
      Tks

      JFB





        • 1. Re: datagrid columns
          Level 7
          Got it to work but not the focus part.
          How can I set the focus in the added row , left column of my datagrid?
          Any ideas?
          Tks

          JFB

          "JFB" <help@jfb.com> wrote in message
          news:f56iua$cj$1@forums.macromedia.com...
          > public function addDataRow():void{
          > //acPrice = new ArrayCollection;
          > var tempObj:Object = new Object();
          > tempObj.priceid = 0;
          > tempObj.estimateid = 0;
          > tempObj.qty = 0;
          > tempObj.perpiece = 0;
          > tempObj.per1000 = 0;
          > tempObj.setupfee = 0;
          > tempObj.total = 0;
          >
          > acPrice.addItemAt(tempObj, price_dg.selectedIndex + 1);
          >
          > this.price_dg.dataProvider = acPrice;
          > this.price_dg.editable = true;
          > }
          >
          > Hi All,
          > This is my function to add a line on my datagrid. I want to create a
          > generic function like
          > public function addDatagridRow(columns:???, myArray:ArrayCollection,
          > myDataGrid:String):void{
          > var tempObj:Object = new Object();
          > ??????
          > myArray.addItemAt(tempObj, myDataGrid.selectedIndex + 1);
          >
          > myDataGrid.dataProvider = myArray;
          > myDataGrid.editable = true;
          > ???
          > }
          > How can I get automatic all the columns from my dataGrid?
          > How can I get each column to setup myTempObj?
          > How can I set the focus in the added row , left column of my datagrid?
          > Tks
          >
          > JFB
          >
          >
          >
          >
          >


          • 2. Re: datagrid columns
            ntsiii Level 3
            setting selectedIndex = dataProvider.length - 1; //should select the row

            is the dg editable, and you want the first cell in the row to be in edit mode? I don't recll the syntax for this but you should be able to find it in the docs.

            IMPORTANT: Do both of these actions in a separate function, and call that function using callLater() in the "addDatagridRow" function. This gives the UI a chance to draw the new row so there will be something to select.

            Tracy