The following code achieves validation on an editable cell. I am not sure if this is what you are looking for, but this might be a good start point. This example validates for a value < 100 for the price field.
//-----------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" width="800" height="700">
<!--
AUTHOR: Joan Tan
FEATURE: CellRenderer
CATEGORY: editor where you validate the data coming in.
TYPE: Manual
FREQUENCY (1-4): 2
LAST MODIFIED BY: $Author$
FILE LOCATION: $File$
CHANGELIST: $Change$
DATE: $DateTime$
NOTES:
REVISION HISTORY: created file (jtan 10-18-05)
-->
<mx:Script>
<![CDATA[
import mx.collections.*;
import mx.controls.dataGridClasses.*;
import mx.controls.listClasses.*;
import mx.collections.*;
import mx.controls.TextInput;
import mx.events.DataGridEvent ;
[Bindable]
public var catArray:ArrayCollection;
public var catArr:Array = [
{ name: "USB Watch",
data: "1",
price: 129.99,
image: "assets/products/usbwatch.jpg",
phone: "433-545-5526",
thumbnail: "assets/products/usbwatch_sm.jpg",
description: "You're mousing over the watch." },
{ name: "007 Digital Camera",
data: "1",
price: 99.99,
phone: "553-545-6426",
image: "assets/products/007camera.jpg",
thumbnail: "assets/products/007camera_sm.jpg",
description: "You're mousing over the camera." },
{ name: "2-Way Radio Watch",
data: "1",
price: 49.9109,
phone: "479-545-9999",
image: "assets/products/radiowatch.jpg",
thumbnail: "assets/products/radiowatch_sm.jpg",
description: "You're mousing over the watch." },
{ name: "Wireless Antenna",
data: "1",
price: 49.99,
phone: "934-254-5526",
image: "assets/products/cantena.jpg",
thumbnail: "assets/products/cantena_sm.jpg",
description: "You're mousing over the cantena."}
];
public function initDataGrid()
{
catArray = new ArrayCollection(catArr);
myList.dataProvider=catArray;
}
public function validateData(event:DataGridEvent)
{
if(event.columnIndex==0)
{
var fCell:Object={columnIndex:event.columnIndex, rowIndex: event.rowIndex};
var newData:Object = TextInput(myList.itemEditorInstance).text;
text1.text = String(newData);
if(newData < 100)
{
text1.text = "Invalid Data was provided. Please provide a value over 100.";
myList.editedItemPosition = fCell;
event.preventDefault();
}
}
else
{
event.preventDefault();
}
}
]]>
</mx:Script>
<mx:PhoneNumberValidator id="validator1" enabled="true"/>
<mx:Label fontSize="15" text="DataGrid with itemEditorInstance that we validate." />
<mx:Text width="350" text="Directions: Click on a cell in the first column. enter a new value over 100 and change cells. Ensure that the
editor went away. Now, click on another cell and enter a value less than 100. Ensure that you get a warning and the editor does not go away." />
<mx:Text id="text1" width="200" color="0xFF0000" />
<mx:DataGrid id="myList" creationComplete="initDataGrid();" editable="true" width="500" rowHeight="60" height="400"
itemEditEnd="validateData(event)" >
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="price" />
<mx:DataGridColumn dataField="image" headerText="Photo" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>
Thanks
Harish
On 11/8/06,
Stephen Gilson <[EMAIL PROTECTED]> wrote:
Hi Valy,This issue will be fixed in the upcoming Flex release. I'm not aware of a workaround, but maybe someone else in the group had come up with one.Stephen
From: [EMAIL PROTECTED]ups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Valy Sivec
Sent: Tuesday, November 07, 2006 2:27 PM
To: [EMAIL PROTECTED]ups.com
Subject: Re: [flexcoders] checkCellRender Validation
Hi Stephen,
Sorry, didn't realize that the page was part of the frame... Here is the document I was referencing: http://livedocs.macromedia.com/flex/2/docs/00000867.html
The ! tasks I have seems pretty basic, have a grid with multiple columns and only 2 columns should be editable. I want to be able validate the cell content at edit. As you said the reason property of the DataGrid event doen't work correctly and seems that I have ran out of luck trying....
Do you have any work around? Any advice?
I'm kinda stuck right now....
Thank you for the message.
Valy
----- Original Message ----
From: Stephen Gilson <smgil! [EMAIL PROTECTED] e.com>
To: [EMAIL PROTECTED]ups.com
Sent: Tuesday, November 7, 2006 1:24:16 PM
Subject: RE: [flexcoders] checkCellRender Validation
Hi Valy,In Flex 2, there was an issue with the reason property of the DataGridEvent and ListEvent class not being set properly when you change cell focus. Which example is this? The page you mention takes me to a page with no example on it.Stephen
From: [EMAIL PROTECTED] ups.com [mailto:flexcoders@ yahoogroups. com] On Behalf Of Valy Sivec
Sent: Tuesday, November 07, 2006 1:18 AM
To: [EMAIL PROTECTED] ups.com
Subject: RE: [flexcoders] checkCellRender ValidationHello flexcoders,
I've spent the last few hours trying to validate a cell on a editable datagrid without any luck. Do you have any example?. The example from the adobe docs doesn't work :(. It seems that preventDefault( ) always works for tab but not for the mouse....
http://livedocs. macromedia. com/flex/ 2/docs/wwhelp/ wwhimpl/common/ html/wwhelp. htm?context= LiveDocs_ Parts&file=00000857. html#230761
Any help is greatly appreciated,
Thanks,
Valy
Get your email and see which of your friends are online - Right on the new Yahoo.com
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
![]()
SPONSORED LINKS
Software development tool Software development Software development services Home design software Software development company
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
Reply via email to

