And I'm using Flex 3.5 and Adobe Flash Builder 4.0.1
I've come to understand the problem a bit better: it seems that when I edit the cell, then push enter, save() gets called 3x and one of those times has event.reason == "newRow". If after editing the cell I click somewhere outside the cell, then save() gets called twice, and both times event.reason == "other". Oh yeah, and when I push enter, the event.target seems to be for the cell below.
By now I feel that my problem is that I just don't know what I'm doing. The handler gets called a bunch of times and I have no idea how to know why it's being called or if I should ignore what. I was hoping that combinations of calls to:
Would work (the idea is that I stop all these parasitic calls) but they don't do anything. I've read tutorials and such, but they don't seem to help me w/this problem.
Maybe an issue with a custom renderer/editor? If you use default renderer/editor does it still get called multiple times?
Not sure how to answer that. The declaration of the column is as follows:
<mx:DataGridColumn headerText="Value" dataField="parm_value" itemEditor="DataEditor" editorDataField="newData" sortable="false" />
Now, DataEditor.mxml will create a different control, depending on which row on the grid is involved, some of which are custom and others are mx:ComboBoxes or mx:TextInputs or whatever. I just ran some tests, and it seems they behave the same with primitive controls as they do with user-defined ones.
The solution I have in place now sets a flag, which causes the handler (save()) to return immediate, if it is set. I can do this, because the handler throws up an Alert.show(), confirming that the user wants to commit the change. Then, I reset the flag in Alert.show()'s handler. I suppose, the only race condition here could be that the user might be so johnny-on-the-spot that he'd confirm before the other calls to save() could be made, thereby resetting the flag early. As far as I know, that's not impossible. (But as far as I know, the call to Alert.show()'s hander gets put into a queue, behind the other calls to save()) In any case, this is obviously not a generally acceptable solution, and if there isn't one, then someone should be shot.
The column has a custom editor defined in DataEditor.mxml. The entire grid has an itemEditEnd handler. If there is another column without a custom editor, does it exhibit the same problem? Or reconfigure this column to use the default editor. That will help determine if the problem is in DataEditor.mxml
If DataEditor.mxml is a container of an actual editable control, it should properly implement IFocusManagerComponent otherwise you might see symptoms as you have described.
Feel free to post the code for DataEditor.mxml
There's only one editable column on this screen. I don't really know how to make it use the default editor properly. If I remove the itemEditor="DataEditor" then I just get crashes all over the place when editing finishes.
I wouldn't say DataEditor.mxml is a control, but here's the Flex from that file (I won't inundate you w/the AS):
<?xml version="1.0" encoding="utf-8"?>
<mx:FormItem visible="false" > <UBIComponent:ubiComboBox id="cmbExplct" /> <UBIComponent:ubiComboBox id="cmbDateFormat" /> </mx:FormItem>