3 Replies Latest reply on Oct 2, 2007 1:03 PM by Newsgroup_User

    comboBox inside datagrid

    Level 7
      Hi All,
      Let me start with this issue again, maybe someone else can help me.
      I have a comboBox inside a datagrid, preview here in this group somebody
      show me how to create an event in my datagrid to do my calculations
      automatic.
      My problem is that after select an Item in the comboBox I have to click
      somewhere else to fire the event.
      Anybody have an idea or sugestion in how to fix this???
      I will include my code below... tks in advance.

      JFB

      public function setDataPrice(event:DataGridEvent):void{
      if(event.dataField == "serviceItemID") {
      // Disable copying data back to the control.
      event.preventDefault();

      var chosenItem:Object =
      ComboBox(event.currentTarget.itemEditorInstance.dataService_cb).selectedItem;
      var chosenId:int = chosenItem.id;

      acData[data_dg.selectedIndex].serviceItemID = Number(chosenId);
      acData[data_dg.selectedIndex].price =
      chosenItem.serviceItemPrice;
      acData[data_dg.selectedIndex].rate1000 =
      chosenItem.serviceItemRate;
      acData.refresh();
      //

      // Close the cell editor.
      data_dg.destroyItemEditor();

      // Notify the list control to update its display.
      data_dg.dataProvider.notifyItemUpdate(data_dg.editedItemRenderer);
      }

      if(event.dataField == "qty") {
      if (event.currentTarget.itemEditorInstance.text != ""){
      acData[data_dg.selectedIndex].qty =
      Number(event.currentTarget.itemEditorInstance.text);
      acData.refresh();
      }
      }

      }

      <mx:DataGrid id="price_dg" itemEditEnd="calculateRateTotal(event)" x="10"
      y="32" width="590" height="147" editable="true">
      <mx:columns>
      <mx:DataGridColumn headerText="Quantity" dataField="qty"
      labelFunction="formatNumber"/>
      <mx:DataGridColumn headerText="Rate Type" dataField="id"
      rendererIsEditor="true" editorDataField="dummy" width="120">
      <mx:itemRenderer>
      <mx:Component>
      <mx:VBox>
      <mx:ComboBox id="rate_cb" dataProvider="{outerDocument.acRate}"
      labelField="label" width="120"/>
      </mx:VBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>


        • 1. Re: comboBox inside datagrid
          aceinc
          Just taking a guess, but you might try;

          Number(event.currentTarget.itemEditorInstance.text);
          acData.refresh();
          price_dg.invalidateDisplayList();
          }

          This may work, I did not study your code real well and what I was trying to accomplish is to execute price_dg.invalidateDisplayList(); after the data has been modified... so if it needs to go somewhere else try it there instead.

          Paul
          • 2. Re: comboBox inside datagrid
            Level 7
            Thanks for you reply and help.
            No luck, this is not working.
            Any other ideas?
            Also when I get the data and fill my ArrayCollection automatic I want to
            fire the calculations on the grid.
            Rgds

            JFB


            "aceinc" <webforumsuser@macromedia.com> wrote in message
            news:fdpi5q$t8t$1@forums.macromedia.com...
            > Just taking a guess, but you might try;
            >
            > Number(event.currentTarget.itemEditorInstance.text);
            > acData.refresh();
            > price_dg.invalidateDisplayList();
            > }
            >
            > This may work, I did not study your code real well and what I was trying
            > to
            > accomplish is to execute price_dg.invalidateDisplayList(); after the data
            > has
            > been modified... so if it needs to go somewhere else try it there instead.
            >
            > Paul
            >


            • 3. Re: comboBox inside datagrid
              Level 7
              Anybody else can help me with this.
              Tks

              JFB

              "JFB" <help@jfb.com> wrote in message
              news:fdhugi$6p6$1@forums.macromedia.com...
              > Hi All,
              > Let me start with this issue again, maybe someone else can help me.
              > I have a comboBox inside a datagrid, preview here in this group somebody
              > show me how to create an event in my datagrid to do my calculations
              > automatic.
              > My problem is that after select an Item in the comboBox I have to click
              > somewhere else to fire the event.
              > Anybody have an idea or sugestion in how to fix this???
              > I will include my code below... tks in advance.
              >
              > JFB
              >
              > public function setDataPrice(event:DataGridEvent):void{
              > if(event.dataField == "serviceItemID") {
              > // Disable copying data back to the control.
              > event.preventDefault();
              >
              > var chosenItem:Object =
              > ComboBox(event.currentTarget.itemEditorInstance.dataService_cb).selectedItem;
              > var chosenId:int = chosenItem.id;
              >
              > acData[data_dg.selectedIndex].serviceItemID =
              > Number(chosenId);
              > acData[data_dg.selectedIndex].price =
              > chosenItem.serviceItemPrice;
              > acData[data_dg.selectedIndex].rate1000 =
              > chosenItem.serviceItemRate;
              > acData.refresh();
              > //
              >
              > // Close the cell editor.
              > data_dg.destroyItemEditor();
              >
              > // Notify the list control to update its display.
              >
              > data_dg.dataProvider.notifyItemUpdate(data_dg.editedItemRenderer);
              > }
              >
              > if(event.dataField == "qty") {
              > if (event.currentTarget.itemEditorInstance.text != ""){
              > acData[data_dg.selectedIndex].qty =
              > Number(event.currentTarget.itemEditorInstance.text);
              > acData.refresh();
              > }
              > }
              >
              > }
              >
              > <mx:DataGrid id="price_dg" itemEditEnd="calculateRateTotal(event)" x="10"
              > y="32" width="590" height="147" editable="true">
              > <mx:columns>
              > <mx:DataGridColumn headerText="Quantity" dataField="qty"
              > labelFunction="formatNumber"/>
              > <mx:DataGridColumn headerText="Rate Type" dataField="id"
              > rendererIsEditor="true" editorDataField="dummy" width="120">
              > <mx:itemRenderer>
              > <mx:Component>
              > <mx:VBox>
              > <mx:ComboBox id="rate_cb" dataProvider="{outerDocument.acRate}"
              > labelField="label" width="120"/>
              > </mx:VBox>
              > </mx:Component>
              > </mx:itemRenderer>
              > </mx:DataGridColumn>
              >