Hi,

I have a complex code for AdvancedDatagrid where I use 7 locked
columns and 4 dynamic item renders, which run through a loop and
multiply. I had the data recycling issue which was fixed by usage of
set data and if else condition maintaining state, but now a different
issue has popped up.

Now some extra cells are created on the corner of the grid. I cannot
pinpoint the cause of this behaviour, if anyone can suggest me what is
wrong with the code.



Here is the code for the renderer:



<?xml version="1.0" encoding="utf-8"?>
<mx:TextInput
    click="onClickHandler(event)"
    width="50"
    height="20"
    styleName="sfdcTextInput"
    visible="true"
    includeInLayout="true"
    restrict="0-9"
    maxChars="8"
    focusOut="NoUserChanged(event)"
    focusIn="keepLastValue(event)"
    text="{UserCount}"
    xmlns:mx="http://www.adobe.com/2006/mxml";>
    <mx:Script>
        <![CDATA[
            import org.puremvc.as3.patterns.facade.Facade;
            import mx.collections.IViewCursor;
            import mx.managers.CursorManager;
            import mx.formatters.CurrencyFormatter;
            import mx.formatters.NumberFormatter;
            import com.fujitsu.app.ApplicationFacade;
            import
mx.controls.advancedDataGridClasses.AdvancedDataGridListData;
            import mx.collections.ArrayCollection;
            import mx.core.Application;
            import mx.formatters.NumberBaseRoundType;



            private var columnDataField:String = "";
            private var _userCount:String;

            public var m_verticalScrollPos:Number = 0; //Sets the
position before refreshing the datagrid. Used in Validate
click

            private var iOldValue:Number;
            private var iNewValue:Number;

            private function keepLastValue(evt:Event):void{
                iOldValue = Number(this.text);
            }

            [Bindable]
            public function get UserCount():String
            {
                return _userCount;
            }

            public function set UserCount(value:String):void
            {
                _userCount = value;
            }



            public override function set data( value:Object ) : void
            {
                super.data = value;
                getData(value);
            }



            private function getData(dataList:Object):void
            {
                columnDataField = AdvancedDataGridListData
(listData).dataField;
                getNoOfUser();
                checkIfLock();
            }

            /***
             * This function will check whether the opportunity is
Lock or not
             * **/
            private function checkIfLock():void
            {
                if(Application.application.m_blOptyLock)
                {
                    this.enabled = false;
                }
            }

            /***
             * This function is the event handler for the text inputs
change event
             * and will compute totals based on the requirement
             * **/
            private function NoUserChanged(evt:Event):void
            {
                if(this.text == "") this.text = "0";
                iNewValue = Number(this.text);
                if(iOldValue == iNewValue){
                    //this.focusManager.getNextFocusManagerComponent
();
                    return;
                }
                callLater(UpdateAmount);
            }

            private function UpdateAmount():void
            {
                var totalUser:Number = 0;
                var totalAmt:Number = 0;

                // Get the assigned Location Information
                for each(var item:Object in data.Location)
                {
                    // If dataField == the name of the location
                    if(columnDataField==item.objName)
                    {
                        item.allocUser = (this.text=="")? 0:Number
(this.text);
                        //var intNoUser:Number = item.allocUser;
                        if(data.UserBased)
                        {
                            item.allocAmt = computeAmt
(data.AllocAmt,data.AllocUser,item.allocUser);
                        }
                        UserCount = item.allocUser;
                        totalUser+=item.allocUser;
                        //item.allocAmt = int(item.allocAmt*100)/100;
                        totalAmt+=item.allocAmt;
                    }
                    else
                    {
                        totalUser+=item.allocUser;
                        //item.allocAmt = int(item.allocAmt*100)/100;
                        totalAmt
+=item.allocAmt;
                    }
                }
                // Round Off
                //totalUser = int(totalUser*100)/100;
                //totalAmt = int(totalAmt*100)/100;
                totalAmt = Number(Number(totalAmt).toFixed(2));
                data.TotalUser = totalUser;
                data.TotalAmt = Math.round(totalAmt);
                // Update background ErrorIndicator
                var isError:Boolean = false;
                if(data.TotalUser != data.AllocUser)
                {
                    isError=true;
                    Application.application.AddToUserArray
(data.ProductName);
                }
                else
                {
                    Application.application.RemoveToUserArray
(data.ProductName);
                }

                if(data.TotalAmt != data.AllocAmt)
                {
                    isError=true;
                    Application.application.AddToAmtArray
(data.ProductName);
                }
                else
                {
                    Application.application.RemoveToAmtArray
(data.ProductName);
                }

                // Update background ErrorIndicator
                data.isErrorRow  = (isError)? true:false;
 
m_verticalScrollPos=this.parentApplication.dgAllocation.verticalScrollPosition;
                // Refresh Data and Grid UI
 
this.parentApplication.dgAllocation.dataProvider.refresh();
                //
this.parentApplication.dgAllocation.dataProvider.refresh(); =
this.parentApplication.dgAllocation.dataProvider;
                validateNow();
 
this.parentApplication.dgAllocation.verticalScrollPosition =
m_verticalScrollPos;
            }

            /***
             * This function wil compute the Amount when Quote Line is
User-Based
             * **/
            private function computeAmt
(intQuoteSalesPrice:Number,intQuoteNoUser:Number,
                                        intLocNoUser:Number):Number
            {
                var retVal:Number = 0;
                if(intQuoteNoUser!=0)
                {
                    var computedAmt:Number = intLocNoUser*
(intQuoteSalesPrice/intQuoteNoUser);
                    // round to 2 decimal places
                    //retVal = int(computedAmt*100)/100;
                    retVal = Number(Number(computedAmt).toFixed(2));
                }
                else
                {
                    retVal = 0;
                }
                return retVal;
            }

            /**
             * Function to handle click event. If the Textbox is
enabled then it will set focus to this field.
             * This is useful to handle focus in and out event. Event
handler added by Siddhesh Kabe
             *
             * **/
            private function onClickHandler(evt:Event):void{
                if(this.enabled){
                    this.focusManager.getFocus().setFocus();
                }
            }

            /***
             * This function will retrieve the no of user value from
the Array of
             * Location. If not found then make the gray mark visible
             * **/
            private function getNoOfUser():Boolean
            {
                var found:Boolean = false;

                if(data != null && data.Location != null)
                {
                    for each(var item:Object in
AdvancedDataGridListData(listData).item.Location)
                    {
                        if(this.columnDataField == item.objName)
                        {
                            UserCount = item.allocUser;
                            found = true;
                            break;
                        }
                    }
                }
                if(!found)
                {
                    this.visible = false;
                    this.includeInLayout = false;
                    this.editable = false;
                    this.enabled = false;
                    //validateNow();
                    //ApplicationFacade.getInstance
().m_locationItemRecord.refresh();
                }else{
                    /**/this.visible = true;
                    this.includeInLayout = true;
                    this.editable = true;
                    this.enabled = true;/**/
                }
                return found;
            }



        ]]>
    </mx:Script>
</mx:TextInput>

I am at my nuts end to find the bug, please please help me out here!!!!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to