flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darrell Loverin <darrell.love...@gmail.com>
Subject Re: spark Datagrid GridItemEditorEvent firing twice
Date Thu, 07 Nov 2013 12:39:04 GMT
What are the values of the  target and eventPhase fields for each of the
two save events?



-Darrell Loverin


On Thu, Nov 7, 2013 at 4:37 AM, Paul Hastings <paul.hastings@gmail.com>wrote:

> i have a spark datagrid that is firing off two
> GridItemEditorEvent.GRID_ITEM_EDITOR_SESSION_SAVE events for a single
> edit. no popups or custom item editors are involved & it seems to happen
> with both the user tabbing out or using the enter key to save the edited
> data. the datagrid has only the one editable column.
>
> everything's working as planned just that it's doubled up (i can see two
> rows in the transaction table for every singe edit on the datagrid).
>
> is listening for GridItemEditorEvent.GRID_ITEM_EDITOR_SESSION_SAVE the
> correct approach? some magic i should be doing to the event or datagrid? i
> vaguely recall there maybe being something on alex's blog about preventing
> extra events but i'm not finding anything related (or likely not searching
> w/the right keyword).
>
> thanks.
>
> if it matters:
>
> adding the event listener:
> workOrdersDG.addEventListener(GridItemEditorEvent.GRID_ITEM_
> EDITOR_SESSION_SAVE,onEditSave,false);
>
> event handler (sorry for the formatting mess):
> protected function onEditSave(event:GridItemEditorEvent):void {
>  errMsg.text="";
>  var item:Object=(event.currentTarget.dataProvider).
> getItemAt(event.rowIndex);
>  var mData:String=item.meterData;
>  if (mData !="" && isNaN(Number(mData))) {
>
> (event.currentTarget.dataProvider).getItemAt(event.rowIndex)[event.column.
> dataField]="";
>   (event.currentTarget.dataProvider).getItemAt(event.
> rowIndex)["usage"]="0";
>   workOrdersDG.selectedIndex=event.rowIndex;
>   errMsg.text="Meter data must be numeric."
> } else {
>  if(Number(item.meterData) >=item.lastCollectedData) {
>
> (event.currentTarget.dataProvider).getItemAt(event.
> rowIndex)["usage"]=Number(item.meterData)-item.lastCollectedData;
>  // send back to server
>  assetService.updateWalkOrderMeterData(item.id,item.meterData,userID);
>  } else
>   errMsg.text="Current meter data must be greater than last collected
> data."
> }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message