1 Reply Latest reply on Dec 19, 2011 2:53 PM by Flex harUI

    How to display errorString in a Datagrid ItemEditor?


      I want to display the error message in the item editor , like this:


      and this is my handler:


       * validate user input.
      protected function datagirdTest_itemEditEndHandler(event:DataGridEvent):void {
      if(event.dataField != "Name") { // check the field;
      var editor:TextInput = datagirdTest.itemEditorInstance as TextInput;
      var input:String = editor.text; // get the user input data.
      if(input == null || input == "") {
      // event.preventDefault(); // prevent default behavior
      editor.errorString = "User name cannot be empty!";
      // datagirdTest.destroyItemEditor();
      }else {
      editor.errorString = null;

      Now I can display the error mesg as the above screen capture, but if the user want to reload the data or sort the column, the editor will stay there until I call datagrid.destroyItemEditor(), but:

      “This method closes an item editor currently open on an item renderer. You typically only call this method from within the event listener for the itemEditEnd event, after you have already called the preventDefault() method to prevent the default event listener from executing.”http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/DataGrid.ht ml#destroyItemEditor()

      so, How can I display the error message in this way?