I have problem with the IGridItemEditor.save() method. 

According to the docs for save()...if the data isn't valid, then the data isn't 
saved and the editor is not closed.

So I setup an example to test this, and its seems ok. However, once I enter 
valid data and hit the Tab key, I expect the next column to contain the 
itemEditor. Instead its the column after that (which isnt correct).

Maybe i'm going about this the wrong way, so any advice would be great.
--
heres a little example demonstrating the problem.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"; 
                           xmlns:s="library://ns.adobe.com/flex/spark" 
                           xmlns:mx="library://ns.adobe.com/flex/mx" 
minWidth="955" minHeight="600">
 <s:layout>
  <s:VerticalLayout horizontalAlign="center" paddingTop="10"/>
 </s:layout>


 <!--
  problem: select first cell ...enter rubbish...then enter valid value...then 
tab => this
  doesnt tab to the next cell instead it tabs to the next one after that.       
                        
  whats going on?
 -->

 <fx:Script>
  <![CDATA[                
   import mx.collections.ArrayCollection;

   [Bindable]
   private var myDP:ArrayCollection = new ArrayCollection([
        {col0:"something", col1:4, col2:'goes', col3:'in', col4:'here'},
        {col0:"maybe", col1:3, col2:'this', col3:'one', col4:'as well'},
        {col0:"what", col1:1, col2:'about', col3:'this', col4:'one'},
        {col0:"sean paul", col1:3, col2:'red', col3:'temperature', col4:'um'},
        {col0:"chaka demus", col1:3, col2:'green', col3:'and pliers', 
col4:'um'}     
        ]);             

  ]]>
 </fx:Script>

 <s:Label text="Edit a cell in col0. Enter rubbish, then tab. This will 
highlight error. Then enter 'hello' and tab again....I expect to tab to col1 
not col2"/>

 <s:DataGrid id="dg" editable="true" dataProvider="{myDP}" width="50%">
  <s:columns>
   <s:ArrayList>
    <s:GridColumn dataField="col0" headerText="col0">
     <s:itemEditor>
       <fx:Component>
         <s:DefaultGridItemEditor>
          <fx:Script>
            <![CDATA[

              override public function save():Boolean 
              {
                if(this.value == "hello")
                {
                  this.textArea.errorString = "";

                  super.save();
                  return true;
                }
                else
                {
                  this.textArea.errorString = "Please enter: hello";

                  return false;
                }
              }

           ]]>
          </fx:Script>
         </s:DefaultGridItemEditor>
        </fx:Component>
      </s:itemEditor>
    </s:GridColumn>
    <s:GridColumn dataField="col1" headerText="col1"/>
    <s:GridColumn dataField="col2" headerText="col2"/>
    <s:GridColumn dataField="col3" headerText="col3"/>
    <s:GridColumn dataField="col4" headerText="col4"/>
   </s:ArrayList> 
  </s:columns>
 </s:DataGrid>
        
</s:Application>


Reply via email to