Has anyone done validation on a datagrid cell?

What I am after this something like this:

A user enters the cell, and edits it's contents.
They are able to enter waht they like.
They leave the cell, and the validation fires.
If the cell content is invalid, an Alert is displayed with a message
telling the user what is wrong is displayed, and then the user is
forced back in to that cell to correct their input.

The problem I am having is when the "tab" key is used to move to the next cell.
The original cell fires the "cellFocusOut", but the next cell gets focus.
If the data is in-valid, the alert shows, but when you click on it,
the validation is fired again on the second cell and if it's content
is in-valid, the alert shows again.

If a mouse click is used, it seems to work *better*

...AND I can't seem to change the focus in the "cellFocusOut", but
only on the "cellFocusIn" event...

Has any one else succeeded at this?

Example Code:

<?xml version="1.0"?>
<!-- Simple example No:1 to demonstrate the DataGrid control -->
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
backgroundColor="#FFFFFF">
        <mx:DataGrid
                id="dgTesting"
                dataProvider="{aMyTestValues}"
                creationComplete="gridTest();"
                editable="true"
                hScrollPolicy="auto"    
                keyUp="gridTest(event);"
                cellEdit="cellEdit(event);"
                cellFocusOut="lostFocusTest(event);"    
                cellFocusIn="gotFocusTest(event);"                      
                >
                <mx:columns>
                        <mx:Array>
                                <mx:DataGridColumn columnName="one" />
                                <mx:DataGridColumn columnName="two" />
                                <mx:DataGridColumn columnName="three" />
                                <mx:DataGridColumn columnName="four" />
                                <mx:DataGridColumn columnName="five" />         
                
                                <mx:DataGridColumn columnName="six" />          
                
                        </mx:Array>
                </mx:columns>
        </mx:DataGrid>

        <mx:Array id="aMyTestValues">
                <mx:Object>
                <one>Pavement</one>
                        <two>9.99</two>
                        <three>Slanted and Enchanted</three>
                        <four>Slanted and Enchanted</four>
                        <five>Slanted and Enchanted</five>
                        <six>Slanted and Enchanted</six>
            </mx:Object>
        </mx:Array>
        <mx:Script>
                <![CDATA[

                        var TAB_KEY = 9;

                        
                        function lostFocusTest(event):Void{
                                trace("lostFocusTest(event)");          
                                mx.core.Application.alert("Lost focus : My 
Message would be in
here if cell is invalid...");
                        }
                        function gotFocusTest(event):Void{
                                trace("gotFocusTest(event)");
                        }

                        function testFunction(event):Void{
                                trace("you press a key!" + event.ascii);
                                if(event.ascii == TAB_KEY){ break; }
                        }
                        function cellEdit(event):Void{
                                trace("cellEdit(event)");
                        }

                        function gridTest(event):Void{
                                trace("gridTest(event)");
                                
                        }
                ]]>
        </mx:Script>
</mx:Application>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to