2 Replies Latest reply on Mar 16, 2012 9:37 AM by lee704

    Spark syntax for mx:ComboBox editorDataField

    lee704 Level 1

      I have an mx:ComboBox that I am converying to Spark.  In mx, I used the editorDataField to bind the value selected in a NumericStepper.  Below is the code.

       

      <mx:DataGridColumn dataField="weight"

                                                 headerText="Estimated Weight (pounds)"

                                                 editable="true"

                                                 width="150"

                                                 editorDataField="value"

                                                 textAlign="right">

                <mx:itemEditor>

                          <mx:Component>

                                    <mx:NumericStepper minimum="0"

                                                                               maximum="100000"

                                                                               stepSize="1"/>

                          </mx:Component>

                </mx:itemEditor>

      </mx:DataGridColumn>

       

      How do I accomplish this in Spark?  The following throws the error "Cannot resolve attribute 'editorDataField' for component type spark.components.gridClasses.GridColumn.":

       

      <s:GridColumn dataField="weight"

                                      headerText="Estimated Weight (pounds)"

                                      editable="true"

                                      width="150"

                                      editorDataField="value">

                <s:itemEditor>

                          <fx:Component>

                                    <mx:NumericStepper minimum="0"

                                                                               maximum="100000"

                                                                               stepSize="1"/>

                          </fx:Component>

                </s:itemEditor>

      </s:GridColumn>

       

      Thanks for your help!

      Lee

        • 1. Re: Spark syntax for mx:ComboBox editorDataField
          Patel Bharat Level 2

          I think this would be helpful to you. Create a custom component, let say Editor.mxml

          <?xml version="1.0" encoding="utf-8"?>

          <s:GridItemEditor xmlns:fx="http://ns.adobe.com/mxml/2009"

                                                    xmlns:s="library://ns.adobe.com/flex/spark"

                                                    xmlns:mx="library://ns.adobe.com/flex/mx">

           

                    <fx:Script>

                              <![CDATA[

           

                                        // Override the setter to initialize the NumericStepper control

                                        // with the cell data.

                                        override public function set value(newValue:Object):void {

                                                  ns.value = newValue as Number;

                                        }

           

                                        // Override the getter to return the current value of

                                        // the NumericStepper control.

                                        // The save() method updates the data provider element for the

                                        // row of the grid with this value.

                                        override public function get value():Object {

                                                  return ns.value;

                                        }

           

                                        // Override setFocus() to shift focus to the NumericStepper.

                                        override public function setFocus():void {

                                                  ns.setFocus();

                                        }

                              ]]>

                    </fx:Script>

           

                    <s:NumericStepper id="ns" width="100%"

                                                              fontWeight="bold"/>

          </s:GridItemEditor>

           

          And use above class as the column itemEditor.

           

           

          • 2. Re: Spark syntax for mx:ComboBox editorDataField
            lee704 Level 1

            That did the trick.  Thank you so much!!

             

            Lee