1 Reply Latest reply on Jun 21, 2009 7:28 AM by SunilAdobe

    advanceddatagrid data validation











      In the following advanced datagrid function I check for numeric (an overly simple example).  If I pass the edit i commit the value to the database.  If I fail the edit I display a message.  I also want to return the user to the errant advanceddatagrid cell and blank the value.  How do I do this?  I can't seem to find the corrrect properties to update.



      protected function adgValidations_itemEditEndHandler(event:AdvancedDataGridEvent):void




           var editOK:Number = 1



           if (event.dataField == "sortOrder")




                var tmpFieldVal:Number = Number(event.currentTarget.itemEditorInstance.text);



                if (isNaN(tmpFieldVal))



      "Sort Order must be a number");

                     editOK = 0;



                     /*event.currentTarget.itemEditorInstance.text = "";*/

                     /*event.currentTarget.itemEditorInstance.cellfocue = just Exited Cell*/








           if (editOK == 1)

                { /* do the database update */}





      Also, along the same lines, When the user pushes the "Add" button I add a new row to the database, refresh the grid, pass back the database record id to the flex app then want to search down the datagrid rows and highlight the row with that new database record key.

        • 1. Re: advanceddatagrid data validation
          SunilAdobe Adobe Employee

          Hi cebdev,


          Not sure whether this is the most optimal way to do this. But this works for me


          if (isNaN(tmpFieldVal))
                                  editOK = 0;
                                  var editedCell:Object = (AdvancedDataGrid)(event.currentTarget).editedItemPosition;
                                  (AdvancedDataGrid)(event.currentTarget).itemEditorInstance.text = "";
                                  Alert.show("Sort Order must be a number","",Alert.OK,null,function():void {
                                      (AdvancedDataGrid)(event.currentTarget).editedItemPosition = editedCell;


          1. The idea is to get the cell that was being edited

          2. set the text to empty

          3. show the alert on hitting ok of alert, set the edited position to the original

          4. prevent the default handling of the event.


          Hope this helps.