3 Replies Latest reply on Jan 19, 2011 4:23 PM by Flex harUI

    TextInput as itemEditor does not display current value.

    mstacey01 Level 1

      I have an MXDataGridItemRenderer (see below). If I have edited the cell previously with some value, and then exit the cell and then come back to it. When I click on that cell the second time (after already editing it), the value I have previously entered does not show up. How can I get this to happen?

       

      Thanks,

      Matt

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                                xmlns:s="library://ns.adobe.com/flex/spark"
                                xmlns:mx="library://ns.adobe.com/flex/mx"
                                focusEnabled="true"
                                implements="mx.managers.IFocusManagerComponent">

       

          <fx:Script>
              <![CDATA[

                  override public function setFocus():void{
                      amountTextInput.setFocus();
                      amountTextInput.selectAll();
                  }

       

              ]]>
          </fx:Script>

       

          <s:HGroup width="100%" height="100%" horizontalAlign="right" verticalAlign="middle">
         
              <s:TextInput id="amountTextInput"
                       width="100%" height="100%"
                       textAlign="right"
                       change="amountText = amountTextInput.text;"
                       updateComplete="amountText = amountTextInput.text;"
                       focusEnabled="true"
                       editable="true"
                       restrict="[0-9][.]"/>
          </s:HGroup>
      </s:MXDataGridItemRenderer>

        • 1. Re: TextInput as itemEditor does not display current value.
          Flex harUI Adobe Employee

          I think you have to set amountTextInput.text to some property of the data

          object on the dataChange event.

          1 person found this helpful
          • 2. Re: TextInput as itemEditor does not display current value.
            mstacey01 Level 1

            You were right that I needed to set the amountTextInput.text to the data value, but I had to do it when the textInput got focus instead of the change event.

             

             

            <s:TextInput id="amountTextInput"
                             width="100%" height="100%"
                             textAlign="right"
                             change="amountText = amountTextInput.text;"
                             updateComplete="amountText = amountTextInput.text;"
                             focusIn="amountTextInput_focusInHandler(event)"
                             focusEnabled="true"
                             editable="true"
                             restrict="[0-9][.]"/>

             

            protected function amountTextInput_focusInHandler(event:FocusEvent):void
                        {
                            amountTextInput.text = this.data.paymentAmount;
                        }

             

            Thanks for the help!

            • 3. Re: TextInput as itemEditor does not display current value.
              Flex harUI Adobe Employee

              It wouldn't be the change event.  The "dataChange" event is commonly used.

              But as long as it is working for you.