2 Replies Latest reply on Jul 29, 2010 5:36 AM by ArjanDs

    NumericStepper does not update dataProvider/ArrayCollection

    ArjanDs

      I created a editable nummeric stepper, like explained in the flex-in-a-week tutorial but somehow my dataprovider.. the arraycollection does not get updated with the new value and resets the value to the dataproviders value when the field looses focus.

       

      i have gone over the tut a view times, compared the code.. but i cant see why.

       

      the arraycollection is declared bindable

       

      [Bindable] private var provinces:ArrayCollection = new ArrayCollection;

      (being filled by a dataservice)

       

      below the code for the  datagrid:

       

                         <mx:DataGrid dataProvider="{provinces}" width="100%" height="100%" editable="true">
                              <mx:columns>


                                  <--snip removed two colums-->


                                  <mx:DataGridColumn
                                      headerText="Taxlevel"
                                      rendererIsEditor="true">
                                      <mx:itemRenderer>
                                          <fx:Component>
                                              <s:MXDataGridItemRenderer horizontalCenter="0">
                                                  <s:NumericStepper minimum="1" maximum="10"
                                                                    value="{data.TaxLevel}"/>
                                              </s:MXDataGridItemRenderer>
                                          </fx:Component>
                                      </mx:itemRenderer>
                                  </mx:DataGridColumn>

       

      any idea why the dataProvider is not being updated?

        • 1. Re: NumericStepper does not update dataProvider/ArrayCollection
          Flex harUI Adobe Employee

          You have to define the property to be pulled from the editor.  It defaults

          to 'text'.  You'll probably want something else.

           

                                      <mx:DataGridColumn

                                          headerText="Taxlevel"

                                          editorDataField="nsValue"

                                          rendererIsEditor="true">

                                          <mx:itemRenderer>

                                              <fx:Component>

                                                  <s:MXDataGridItemRenderer

          horizontalCenter="0">

          <fx:Script>

          Public function get nsValue():int { return ns.value };

          </fx:Script>

                                                      <s:NumericStepper id="ns"

          minimum="1" maximum="10"

                                                                       

          value="{data.TaxLevel}"/>

                                                  </s:MXDataGridItemRenderer>

                                              </fx:Component>

                                          </mx:itemRenderer>

                                      </mx:DataGridColumn>

           

          1 person found this helpful
          • 2. Re: NumericStepper does not update dataProvider/ArrayCollection
            ArjanDs Level 1

            thanks alex,

             

            At first it still wasnt updating and resetting the values to what is in the arraycollection.

             

            but including dataField="TaxLevel"  as well as  editorDataField="nsValue" in the DataGridColumn did the trick.

             

            below the code for others

             

            <mx:DataGridColumn editorDataField="nsValue" dataField="TaxLevel"

                                            headerText="Taxlevel"

                                            rendererIsEditor="true">

             

                                            <mx:itemRenderer>

                                                <fx:Component>

                                                    <s:MXDataGridItemRenderer>

                                                        <fx:Script>

                                                            <![CDATA[

                                                            public function get nsValue():int { return ns.value };

                                                            ]]>

                                                        </fx:Script>

                                                        <s:NumericStepper id="ns" minimum="1" maximum="10"

                                                                          value="{data.TaxLevel}"/>

                                                    </s:MXDataGridItemRenderer>

                                                </fx:Component>

                                            </mx:itemRenderer>

                                        </mx:DataGridColumn>