Search Flex Components Free

Custom Search

December 20, 2007

Flex Control DataGrid Verifying Edited Data Source Code Sample

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="" backgroundAlpha="0" creationComplete="srv.send()" >
import mx.controls.TextInput; import;
private function initDataGrid() : void { myGrid.dataProvider = srv.lastResult.catalog.product; }
private function validateData(event:DataGridEvent) : void { if(event.dataField == 'price') { var newData:uint = uint(TextInput(myGrid.itemEditorInstance).text);
if(newData < 40) { TextInput(myGrid.itemEditorInstance).errorString = "Invalid Data was provided. Please provide a value over 40.00."; event.preventDefault(); } } }
<mx:HTTPService id="srv" url="../assets/catalog.xml" useProxy="false" result="initDataGrid()" />
<mx:Text width="550" text="In this example, we validate that the edited data for the first column is always over 40.00. Otherwise, we bring up an error message." />
<mx:DataGrid id="myGrid" editable="true" width="500" height="400" itemEditEnd="validateData(event)" > <mx:columns> <mx:DataGridColumn dataField="price" headerText="Price"/> <mx:DataGridColumn dataField="name" headerText="Product" /> </mx:columns></mx:DataGrid>

Related Flex Tutorials