5 Replies Latest reply on Dec 23, 2009 3:06 PM by Flex harUI

    ItemFocusOut and ItemEndEdit triggered twice?

    Christian A. Smith

      I'm running into an issue using advanced datagrid where I call the itemFocusOut event.   For some reason this always gets called twice.  The first call holds the correct values, the second call does not.   I also tried to use ItemEndEdit and it had the same issue.   I've seen this question asked repeatedly across the forum but have yet to see an answer as to why this happens.   Below is my code example for ItemFocusOut.  I will show the ADG setup and the itemFocusOut method.

       

       

      <mx:AdvancedDataGrid id="adg1"         width="800" height="246"         styleName="dstGridReadOnlySorting"         sortExpertMode="true"         headerHorizontalSeparatorSkin="mx.skins.ProgrammaticSkin"         editable="true"         selectionMode="singleCell"         verticalCenter="0"         horizontalCenter="0"         fontSize="12"         itemFocusOut="onItemFocusOut(event)"           >

       

      private function onItemFocusOut(event:AdvancedDataGridEvent):void
      {

       

           var cell:Object = event.currentTarget.selectedCells[0];

               var dataField:String = event.currentTarget.columns[event.columnIndex].dataField;;

       

               if (dataField.toString() == "ACP_VST_PRC" )
               {

       

                  var gridCell:Object = event.itemRenderer.data;
              var nAcpVestingPerc:Number = Number( gridCell.ACP_VST_PRC)
            var nCalcdVstdAdpXcs:Number = Number(gridCell.CALCD_ACP_XCS);
         
                  //Calculate ACP_VESTED column
         
              var nAcpVested:Number = (nAcpVestingPerc / 100) * nCalcdVstdAdpXcs;
          
              if ( nAcpVested > 0 )
              {
                gridCell.ACP_VESTED = nAcpVested;
              }   
          
                  //Calculate Forfeited ACP column
              var nForfeitedAcp:Number = nCalcdVstdAdpXcs - (nCalcdVstdAdpXcs * (nAcpVestingPerc / 100));
            
              if ( nForfeitedAcp > 0 )
              {
                gridCell.FORFEITED_ACP = nForfeitedAcp;
              }
            }  

       

      }
        • 1. Re: ItemFocusOut and ItemEndEdit triggered twice?
          Flex harUI Adobe Employee

          What do you mean by call?  Usually you respond to events, not call them.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: ItemFocusOut and ItemEndEdit triggered twice?
            Christian A. Smith Level 1

            when I said call, I meant system triggered?

            • 3. Re: ItemFocusOut and ItemEndEdit triggered twice?
              Flex harUI Adobe Employee

              Can you show some code?  If there are popups involved, you can definitely get these events more than once.  Or try a testcase with a very generic DataGrid and see if you get multiple events.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: ItemFocusOut and ItemEndEdit triggered twice?
                Christian A. Smith Level 1

                The grid is inside a LayoutContainter (my version of an accordion), which is inside mx:TitleWindow.   So, the window itself is a called pop-up.  I have code at the top of this discussion which shows the ItemFocusOut event for the grid.

                 

                below is the datagrid mxml layout (the SmartDeskAccordionStep is a layoutContainter also dataField ACP_VST_PRC is the only input cell):

                 

                 

                 

                 

                <dst:SmartDeskAccordionStep id="Step1" styleName="dstWorkAssistantStep" width="100%" height="100%"

                label="

                Step 1: Enter the Vesting Percentage for Each Employee" fontSize="14">

                 

                 

                 

                 

                <mx:AdvancedDataGrid id="adg1"

                width="

                800" height="246"

                styleName="

                dstGridReadOnlySorting"

                sortExpertMode="

                true"

                headerHorizontalSeparatorSkin="

                mx.skins.ProgrammaticSkin"

                editable="

                true"

                selectionMode="

                singleCell"

                verticalCenter="

                0"

                horizontalCenter="

                0"

                fontSize="

                12"

                itemFocusOut="onItemFocusOut(event)"

                >

                 

                 

                 

                <mx:columns>

                 

                 

                 

                <mx:AdvancedDataGridColumn dataField="Name1" editable="false" width="170" id="name1"

                headerText="

                Name" headerStyleName="dstGridHeaderText" />

                 

                 

                 

                <mx:AdvancedDataGridColumn dataField="SSN1" editable="false" width="170" id="ssn1"

                headerText="

                SSN" headerStyleName="dstGridHeaderText" />

                 

                 

                 

                <mx:AdvancedDataGridColumn dataField="CALCD_VSTD_ADP_XCS"

                editable="

                false"

                id="

                cALCD_VSTD_ADP_XCS"

                width="

                150"

                headerText="

                Calculated / Vested ADP Excess"

                headerStyleName="

                dstGridHeaderNumeric"

                headerWordWrap="

                true"

                labelFunction="

                currencyLabel"

                textAlign="

                right" >

                 

                 

                </mx:AdvancedDataGridColumn>

                 

                 

                <mx:AdvancedDataGridColumn dataField="FORF_RLTD_ADP_MATCH"

                editable="

                false"

                id="

                fORF_RLTD_ADP_MATCH"

                width="

                150"

                headerText="

                Forfeited Related ADP Match"

                headerStyleName="

                dstGridHeaderNumeric"

                headerWordWrap="

                true"

                labelFunction="

                currencyLabel"

                textAlign="

                right" >

                 

                 

                </mx:AdvancedDataGridColumn>

                 

                 

                <mx:AdvancedDataGridColumn dataField="CALCD_ACP_XCS"

                editable="

                false"

                id="

                cALCD_ACP_XCS"

                width="

                150"

                headerText="

                Calculated ACP Excess"

                headerStyleName="

                dstGridHeaderNumeric"

                headerWordWrap="

                true"

                labelFunction="

                currencyLabel"

                textAlign="

                right" >

                 

                 

                </mx:AdvancedDataGridColumn>

                 

                 

                <mx:AdvancedDataGridColumn dataField="ACP_VST_PRC"

                editable="

                true"

                id="

                aCP_VST_PRC"

                width="

                130"

                headerText="

                ACP Vesting %"

                headerStyleName="

                dstGridHeaderNumeric"

                headerWordWrap="

                true"

                textAlign="

                right">

                <!-- <mx:itemRenderer>

                <mx:Component>

                <dst:SmartDeskPercentInput />

                </mx:Component>

                </mx:itemRenderer>

                -->

                 

                 

                </mx:AdvancedDataGridColumn>

                 

                 

                <mx:AdvancedDataGridColumn dataField="ACP_VESTED"

                editable="

                false"

                id="

                aCP_VESTED"

                width="

                130"

                headerText="

                ACP Vested"

                headerStyleName="

                dstGridHeaderNumeric"

                headerWordWrap="

                true"

                labelFunction="

                currencyLabel"

                textAlign="

                right" >

                 

                 

                </mx:AdvancedDataGridColumn>

                 

                 

                <mx:AdvancedDataGridColumn dataField="FORFEITED_ACP"

                editable="

                false"

                id="

                fORFD_ACP"

                width="

                130"

                headerText="

                Forfeited ACP"

                headerStyleName="

                dstGridHeaderNumeric"

                headerWordWrap="

                true"

                labelFunction="

                currencyLabel"

                textAlign="

                right" >

                 

                 

                </mx:AdvancedDataGridColumn>

                 

                 

                 

                </mx:columns>

                 

                </mx:AdvancedDataGrid>

                 

                • 5. Re: ItemFocusOut and ItemEndEdit triggered twice?
                  Flex harUI Adobe Employee

                  Sounds ok to me.  Maybe try a simple test case with an ADG and see what you get.

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

                  Blog: http://blogs.adobe.com/aharui